@stigmer/runner 3.6.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/.build-fingerprint +1 -1
  2. package/dist/activities/call-agent.js +85 -10
  3. package/dist/activities/call-agent.js.map +1 -1
  4. package/dist/activities/execute-cursor/index.js +39 -5
  5. package/dist/activities/execute-cursor/index.js.map +1 -1
  6. package/dist/activities/execute-cursor/model-pricing.d.ts +9 -0
  7. package/dist/activities/execute-cursor/model-pricing.js +19 -0
  8. package/dist/activities/execute-cursor/model-pricing.js.map +1 -1
  9. package/dist/activities/execute-cursor/service-tier.d.ts +68 -0
  10. package/dist/activities/execute-cursor/service-tier.js +187 -0
  11. package/dist/activities/execute-cursor/service-tier.js.map +1 -0
  12. package/dist/activities/execute-cursor/session-lifecycle.d.ts +16 -1
  13. package/dist/activities/execute-cursor/session-lifecycle.js +12 -4
  14. package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -1
  15. package/dist/activities/execute-cursor/usage-accumulator.d.ts +21 -1
  16. package/dist/activities/execute-cursor/usage-accumulator.js +23 -3
  17. package/dist/activities/execute-cursor/usage-accumulator.js.map +1 -1
  18. package/dist/client/stigmer-client.d.ts +6 -1
  19. package/dist/client/stigmer-client.js +5 -2
  20. package/dist/client/stigmer-client.js.map +1 -1
  21. package/dist/main.js +18 -0
  22. package/dist/main.js.map +1 -1
  23. package/dist/runner.js +48 -0
  24. package/dist/runner.js.map +1 -1
  25. package/dist/sandbox-token-renewal.d.ts +65 -0
  26. package/dist/sandbox-token-renewal.js +169 -0
  27. package/dist/sandbox-token-renewal.js.map +1 -0
  28. package/dist/shared/artifact-storage.d.ts +17 -3
  29. package/dist/shared/artifact-storage.js +22 -4
  30. package/dist/shared/artifact-storage.js.map +1 -1
  31. package/dist/workflow-engine/loader.js +99 -2
  32. package/dist/workflow-engine/loader.js.map +1 -1
  33. package/dist/workflow-engine/tasks/call-agent.d.ts +0 -2
  34. package/dist/workflow-engine/tasks/call-agent.js +0 -2
  35. package/dist/workflow-engine/tasks/call-agent.js.map +1 -1
  36. package/dist/workflow-engine/types.d.ts +39 -7
  37. package/dist/workflow-engine/types.js.map +1 -1
  38. package/dist/workflows/call-agent-orchestrator.d.ts +3 -2
  39. package/dist/workflows/call-agent-orchestrator.js +8 -2
  40. package/dist/workflows/call-agent-orchestrator.js.map +1 -1
  41. package/package.json +2 -2
  42. package/src/__tests__/sandbox-token-renewal.test.ts +174 -0
  43. package/src/activities/__tests__/call-agent-contracts.test.ts +4 -4
  44. package/src/activities/__tests__/call-agent.test.ts +219 -4
  45. package/src/activities/call-agent.ts +94 -10
  46. package/src/activities/execute-cursor/__tests__/model-pricing.test.ts +20 -0
  47. package/src/activities/execute-cursor/__tests__/service-tier.test.ts +170 -0
  48. package/src/activities/execute-cursor/__tests__/usage-accumulator.test.ts +87 -1
  49. package/src/activities/execute-cursor/index.ts +49 -7
  50. package/src/activities/execute-cursor/model-pricing.ts +23 -0
  51. package/src/activities/execute-cursor/service-tier.ts +244 -0
  52. package/src/activities/execute-cursor/session-lifecycle.ts +33 -5
  53. package/src/activities/execute-cursor/usage-accumulator.ts +35 -3
  54. package/src/client/stigmer-client.ts +11 -4
  55. package/src/main.ts +20 -0
  56. package/src/runner.ts +62 -0
  57. package/src/sandbox-token-renewal.ts +212 -0
  58. package/src/shared/artifact-storage.ts +32 -7
  59. package/src/workflow-engine/__tests__/golden-execution.test.ts +8 -8
  60. package/src/workflow-engine/__tests__/loader.test.ts +192 -7
  61. package/src/workflow-engine/__tests__/tasks/call-agent.test.ts +9 -9
  62. package/src/workflow-engine/loader.ts +113 -2
  63. package/src/workflow-engine/tasks/call-agent.ts +0 -2
  64. package/src/workflow-engine/types.ts +40 -7
  65. package/src/workflows/call-agent-orchestrator.ts +8 -2
@@ -120,6 +120,25 @@ export function getCursorModelPricing(model) {
120
120
  console.warn(`Pricing lookup miss for "${model}" (normalized: "${normalized}"), using DEFAULT_PRICING`);
121
121
  return { ...DEFAULT_PRICING, model };
122
122
  }
123
+ /**
124
+ * Look up pricing for a Cursor model under an explicitly requested speed
125
+ * variant (stigmer/stigmer#357). Unlike the suffix inference above — which
126
+ * derives the variant from a wire id like "composer-2.5-fast" — this is for
127
+ * callers that KNOW the variant because they requested it. Falls back to
128
+ * base rates (with a warning) when the registry prices no such variant;
129
+ * create-time validation makes that unreachable short of registry drift.
130
+ */
131
+ export function getCursorModelPricingForVariant(model, variant) {
132
+ const base = getCursorModelPricing(model);
133
+ if (variant !== "fast")
134
+ return base;
135
+ const fast = applyFastVariant(base, model);
136
+ if (fast)
137
+ return fast;
138
+ console.warn(`Requested fast-variant pricing for "${model}" but the registry prices no fast variant — ` +
139
+ `estimating at base rates (billing reconciliation remains authoritative)`);
140
+ return base;
141
+ }
123
142
  /**
124
143
  * Compute USD cost for a single turn.
125
144
  *
@@ -1 +1 @@
1
- {"version":3,"file":"model-pricing.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/model-pricing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK3E;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAE5E;;;GAGG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACrC,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AA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AAU,2BAA2B,CAC1F,CAAC;IACF,OAAO,EAAE,GAAG,eAAe,EAAE,KAAK,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,OAA2B,EAC3B,WAAmB,EACnB,YAAoB,EACpB,gBAAwB,EACxB,eAAuB;IAEvB,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,eAAe,GAAG,gBAAgB,CAAC,CAAC;IACnF,OAAO,CACL,YAAY,GAAG,OAAO,CAAC,oBAAoB;UACzC,YAAY,GAAG,OAAO,CAAC,qBAAqB;UAC5C,gBAAgB,GAAG,OAAO,CAAC,yBAAyB;UACpD,eAAe,GAAG,OAAO,CAAC,wBAAwB,CACrD,GAAG,SAAS,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"model-pricing.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/model-pricing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK3E;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAE5E;;;GAGG;AACH,SAAS,gBAAgB,CAAC,KAAa;IACrC,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CACvB,IAAwB,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AAG,eAAe,EAAE,KAAK,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,+BAA+B,CAC7C,KAAa,EACb,OAAsB;IAEtB,MAAM,IAAI,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,OAAO,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3C,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IACtB,OAAO,CAAC,IAAI,CACV,uCAAuC,KAAK,8CAA8C;QAC1F,yEAAyE,CAC1E,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,OAA2B,EAC3B,WAAmB,EACnB,YAAoB,EACpB,gBAAwB,EACxB,eAAuB;IAEvB,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,eAAe,GAAG,gBAAgB,CAAC,CAAC;IACnF,OAAO,CACL,YAAY,GAAG,OAAO,CAAC,oBAAoB;UACzC,YAAY,GAAG,OAAO,CAAC,qBAAqB;UAC5C,gBAAgB,GAAG,OAAO,CAAC,yBAAyB;UACpD,eAAe,GAAG,OAAO,CAAC,wBAAwB,CACrD,GAAG,SAAS,CAAC;AAChB,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Service-tier → Cursor variant-parameter translation (stigmer/stigmer#357).
3
+ *
4
+ * The platform contract: an execution's model selection is ALWAYS explicit.
5
+ * A bare `{ id }` lets the Cursor catalog's default variant decide the price
6
+ * (observed 2026-08-06: composer-2.5 defaults to fast=true at ~4x base
7
+ * rates, claude-haiku-4-5 to thinking=true), and that default follows an
8
+ * out-of-band account setting. This module pins every price-bearing variant
9
+ * parameter the model declares, so the billed variant is a deterministic
10
+ * function of ExecutionConfig.service_tier:
11
+ *
12
+ * - STANDARD: every price-bearing boolean pinned to its base value
13
+ * (fast=false, thinking=false where the parameter exists).
14
+ * - FAST: fast=true, thinking still pinned false.
15
+ * - Price-neutral parameters (e.g. effort) are deliberately NOT pinned —
16
+ * they follow the catalog default and do not change the bill.
17
+ *
18
+ * Parameter bundles come from Cursor.models.list() (worker-cached): the
19
+ * catalog is the only source of a model's parameter ids, and the fetch
20
+ * rides the same proxy fetch-interceptor as every other SDK call, so it
21
+ * works identically in proxy and direct modes.
22
+ *
23
+ * UNSPECIFIED resolves to STANDARD here and ONLY here — every upstream
24
+ * layer preserves the caller's raw enum so "user chose standard" stays
25
+ * distinguishable from "platform default" all the way to the ledger.
26
+ */
27
+ import type { ModelParameterValue } from "@cursor/sdk";
28
+ import { ServiceTier } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
29
+ /**
30
+ * The effective tier after platform-default resolution: never UNSPECIFIED.
31
+ */
32
+ export type EffectiveServiceTier = ServiceTier.STANDARD | ServiceTier.FAST;
33
+ /** Test-only: drop the worker-level catalog cache. */
34
+ export declare function resetCatalogCacheForTests(): void;
35
+ /**
36
+ * Resolve the configured tier to its effective value. The single place in
37
+ * the platform where UNSPECIFIED becomes STANDARD.
38
+ */
39
+ export declare function resolveEffectiveServiceTier(configured: ServiceTier | undefined): EffectiveServiceTier;
40
+ /** Human-readable tier label for logs and error messages. */
41
+ export declare function serviceTierLabel(tier: ServiceTier): string;
42
+ export interface ResolveServiceTierParamsOptions {
43
+ readonly apiKey: string;
44
+ /** Validated model id the execution runs on (may be "default" for Auto). */
45
+ readonly modelId: string;
46
+ readonly tier: EffectiveServiceTier;
47
+ /** For log correlation only. */
48
+ readonly executionId: string;
49
+ }
50
+ /**
51
+ * Translate the effective tier into the explicit variant parameters to send
52
+ * with every Agent.create/resume for this execution.
53
+ *
54
+ * Fail-closed posture: FAST with no pinnable fast dimension is an error,
55
+ * never a silent downgrade — create-time validation makes this unreachable
56
+ * unless the registry and the provider catalog have drifted, and that drift
57
+ * must be heard about, not absorbed.
58
+ *
59
+ * STANDARD degrades to empty params on catalog failures rather than failing
60
+ * the execution — but be clear about what that costs: an unpinned selection
61
+ * falls to the catalog default variant, which for several models IS the
62
+ * fast/thinking variant at multiples of base rates (the incident this module
63
+ * exists to prevent). Failing every standard execution whenever the catalog
64
+ * endpoint blips would be the worse trade; the WARN below plus billing's
65
+ * requested-vs-billed mismatch alarm (which catches exactly this window)
66
+ * are the compensating controls.
67
+ */
68
+ export declare function resolveServiceTierParams(options: ResolveServiceTierParamsOptions): Promise<ModelParameterValue[]>;
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Service-tier → Cursor variant-parameter translation (stigmer/stigmer#357).
3
+ *
4
+ * The platform contract: an execution's model selection is ALWAYS explicit.
5
+ * A bare `{ id }` lets the Cursor catalog's default variant decide the price
6
+ * (observed 2026-08-06: composer-2.5 defaults to fast=true at ~4x base
7
+ * rates, claude-haiku-4-5 to thinking=true), and that default follows an
8
+ * out-of-band account setting. This module pins every price-bearing variant
9
+ * parameter the model declares, so the billed variant is a deterministic
10
+ * function of ExecutionConfig.service_tier:
11
+ *
12
+ * - STANDARD: every price-bearing boolean pinned to its base value
13
+ * (fast=false, thinking=false where the parameter exists).
14
+ * - FAST: fast=true, thinking still pinned false.
15
+ * - Price-neutral parameters (e.g. effort) are deliberately NOT pinned —
16
+ * they follow the catalog default and do not change the bill.
17
+ *
18
+ * Parameter bundles come from Cursor.models.list() (worker-cached): the
19
+ * catalog is the only source of a model's parameter ids, and the fetch
20
+ * rides the same proxy fetch-interceptor as every other SDK call, so it
21
+ * works identically in proxy and direct modes.
22
+ *
23
+ * UNSPECIFIED resolves to STANDARD here and ONLY here — every upstream
24
+ * layer preserves the caller's raw enum so "user chose standard" stays
25
+ * distinguishable from "platform default" all the way to the ledger.
26
+ */
27
+ import { Cursor } from "@cursor/sdk";
28
+ import { ServiceTier } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
29
+ /**
30
+ * Catalog ids that mean "Cursor picks the model" (Auto). Auto's single
31
+ * catalog variant has an empty parameter set — there is no tier dimension
32
+ * to pin, a documented v1 limitation. Create-time validation refuses FAST
33
+ * without a pinned model, so FAST can only reach Auto through registry
34
+ * drift — handled as a loud failure below.
35
+ */
36
+ const AUTO_MODEL_IDS = new Set(["default", "auto"]);
37
+ /**
38
+ * Variant parameter ids that change the per-token price. Pinning exactly
39
+ * these keeps the bill deterministic while leaving latency/effort knobs on
40
+ * their catalog defaults. Sourced from the Cursor catalog survey
41
+ * (stigmer-cloud _projects/2026-08/20260806.04.model-service-tier).
42
+ */
43
+ const FAST_PARAM_ID = "fast";
44
+ const THINKING_PARAM_ID = "thinking";
45
+ const CATALOG_CACHE_TTL_MS = 3_600_000; // 1 hour, matching the pricing table TTL
46
+ let catalogCache = null;
47
+ // Keyed by apiKey: a worker normally serves one org's key, but nothing
48
+ // enforces that — handing execution A a catalog fetched under execution B's
49
+ // key would leak another account's model availability into A's translation.
50
+ let inflightCatalogFetch = null;
51
+ /** Test-only: drop the worker-level catalog cache. */
52
+ export function resetCatalogCacheForTests() {
53
+ catalogCache = null;
54
+ inflightCatalogFetch = null;
55
+ }
56
+ /**
57
+ * Resolve the configured tier to its effective value. The single place in
58
+ * the platform where UNSPECIFIED becomes STANDARD.
59
+ */
60
+ export function resolveEffectiveServiceTier(configured) {
61
+ return configured === ServiceTier.FAST ? ServiceTier.FAST : ServiceTier.STANDARD;
62
+ }
63
+ /** Human-readable tier label for logs and error messages. */
64
+ export function serviceTierLabel(tier) {
65
+ switch (tier) {
66
+ case ServiceTier.FAST:
67
+ return "fast";
68
+ case ServiceTier.STANDARD:
69
+ return "standard";
70
+ default:
71
+ return "unspecified";
72
+ }
73
+ }
74
+ async function listCatalogModels(apiKey) {
75
+ const now = Date.now();
76
+ if (catalogCache && catalogCache.apiKey === apiKey && catalogCache.expiresAt > now) {
77
+ return catalogCache.models;
78
+ }
79
+ if (inflightCatalogFetch?.apiKey === apiKey)
80
+ return inflightCatalogFetch.promise;
81
+ let entry = null;
82
+ const promise = (async () => {
83
+ try {
84
+ const models = await Cursor.models.list({ apiKey });
85
+ catalogCache = { apiKey, models, expiresAt: Date.now() + CATALOG_CACHE_TTL_MS };
86
+ return models;
87
+ }
88
+ finally {
89
+ // Clear only our own entry — a concurrent fetch under another key may
90
+ // have replaced it.
91
+ if (inflightCatalogFetch === entry) {
92
+ inflightCatalogFetch = null;
93
+ }
94
+ }
95
+ })();
96
+ entry = { apiKey, promise };
97
+ inflightCatalogFetch = entry;
98
+ return promise;
99
+ }
100
+ function findCatalogModel(models, modelId) {
101
+ return models.find((m) => m.id === modelId || m.aliases?.includes(modelId));
102
+ }
103
+ /**
104
+ * Translate the effective tier into the explicit variant parameters to send
105
+ * with every Agent.create/resume for this execution.
106
+ *
107
+ * Fail-closed posture: FAST with no pinnable fast dimension is an error,
108
+ * never a silent downgrade — create-time validation makes this unreachable
109
+ * unless the registry and the provider catalog have drifted, and that drift
110
+ * must be heard about, not absorbed.
111
+ *
112
+ * STANDARD degrades to empty params on catalog failures rather than failing
113
+ * the execution — but be clear about what that costs: an unpinned selection
114
+ * falls to the catalog default variant, which for several models IS the
115
+ * fast/thinking variant at multiples of base rates (the incident this module
116
+ * exists to prevent). Failing every standard execution whenever the catalog
117
+ * endpoint blips would be the worse trade; the WARN below plus billing's
118
+ * requested-vs-billed mismatch alarm (which catches exactly this window)
119
+ * are the compensating controls.
120
+ */
121
+ export async function resolveServiceTierParams(options) {
122
+ const { apiKey, modelId, tier, executionId } = options;
123
+ const tierName = serviceTierLabel(tier);
124
+ if (AUTO_MODEL_IDS.has(modelId)) {
125
+ if (tier === ServiceTier.FAST) {
126
+ throw new Error(`service_tier=fast requires a pinned model — Auto ("${modelId}") has no ` +
127
+ `tier dimension. Execution ${executionId} should have been refused at ` +
128
+ `create time; the model registry and provider catalog may have drifted.`);
129
+ }
130
+ console.log(`ServiceTier: execution=${executionId} model=${modelId} tier=${tierName} — ` +
131
+ `Auto has no variant parameters; Cursor picks the model and variant ` +
132
+ `(documented v1 limitation).`);
133
+ return [];
134
+ }
135
+ let models;
136
+ try {
137
+ models = await listCatalogModels(apiKey);
138
+ }
139
+ catch (err) {
140
+ if (tier === ServiceTier.FAST) {
141
+ throw new Error(`service_tier=fast for execution ${executionId} needs the Cursor model ` +
142
+ `catalog to resolve variant params for "${modelId}", and the catalog ` +
143
+ `fetch failed: ${err instanceof Error ? err.message : String(err)}`);
144
+ }
145
+ console.warn(`ServiceTier UNPINNED: execution=${executionId} model=${modelId} tier=${tierName} — ` +
146
+ `catalog fetch failed (${err instanceof Error ? err.message : err}); ` +
147
+ `sending no variant params, so the catalog DEFAULT variant decides the ` +
148
+ `price for this execution (fast/thinking on several models — the ` +
149
+ `expensive direction). Billing's requested-vs-billed mismatch alarm ` +
150
+ `covers this window.`);
151
+ return [];
152
+ }
153
+ const model = findCatalogModel(models, modelId);
154
+ if (!model) {
155
+ if (tier === ServiceTier.FAST) {
156
+ throw new Error(`service_tier=fast requested for "${modelId}" (execution ${executionId}) ` +
157
+ `but the Cursor catalog does not list that model — cannot pin a fast ` +
158
+ `variant. The model registry and provider catalog have drifted.`);
159
+ }
160
+ console.warn(`ServiceTier UNPINNED: execution=${executionId} model=${modelId} tier=${tierName} — ` +
161
+ `model not in the Cursor catalog; sending no variant params, so the ` +
162
+ `catalog DEFAULT variant decides the price for this execution.`);
163
+ return [];
164
+ }
165
+ const params = [];
166
+ for (const def of model.parameters ?? []) {
167
+ if (def.id === FAST_PARAM_ID) {
168
+ params.push({ id: FAST_PARAM_ID, value: tier === ServiceTier.FAST ? "true" : "false" });
169
+ }
170
+ else if (def.id === THINKING_PARAM_ID) {
171
+ params.push({ id: THINKING_PARAM_ID, value: "false" });
172
+ }
173
+ // Any other parameter (e.g. effort) is price-neutral: left to the
174
+ // catalog default variant on purpose.
175
+ }
176
+ if (tier === ServiceTier.FAST && !params.some((p) => p.id === FAST_PARAM_ID)) {
177
+ throw new Error(`service_tier=fast requested for "${modelId}" (execution ${executionId}) ` +
178
+ `but the Cursor catalog declares no "fast" parameter for it. The model ` +
179
+ `registry prices a fast variant the provider no longer offers — refusing ` +
180
+ `rather than silently billing an unknown variant.`);
181
+ }
182
+ params.sort((a, b) => a.id.localeCompare(b.id));
183
+ console.log(`ServiceTier: execution=${executionId} model=${modelId} tier=${tierName} ` +
184
+ `params=${JSON.stringify(params)}`);
185
+ return params;
186
+ }
187
+ //# sourceMappingURL=service-tier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-tier.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/service-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAO3F;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAErC,MAAM,oBAAoB,GAAG,SAAS,CAAC,CAAC,yCAAyC;AAQjF,IAAI,YAAY,GAAwB,IAAI,CAAC;AAC7C,uEAAuE;AACvE,4EAA4E;AAC5E,4EAA4E;AAC5E,IAAI,oBAAoB,GAA4F,IAAI,CAAC;AAEzH,sDAAsD;AACtD,MAAM,UAAU,yBAAyB;IACvC,YAAY,GAAG,IAAI,CAAC;IACpB,oBAAoB,GAAG,IAAI,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,UAAmC;IAEnC,OAAO,UAAU,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC;AACnF,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,gBAAgB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AAI,KAAK,WAAW,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,aAAa,CAAC,EAAE,CAAC;QAC7E,MAAM,IAAI,KAAK,CACb,oCAAoC,OAAO,gBAAgB,WAAW,IAAI;YAC1E,wEAAwE;YACxE,0EAA0E;YAC1E,kDAAkD,CACnD,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CACT,0BAA0B,WAAW,UAAU,OAAO,SAAS,QAAQ,GAAG;QAC1E,UAAU,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CACnC,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -35,11 +35,20 @@
35
35
  * the user message plus re-injected instructions — there is no separate
36
36
  * continuation store.
37
37
  */
38
- import type { SDKAgent, CursorAgentPlatformOptions, AgentDefinition } from "@cursor/sdk";
38
+ import type { SDKAgent, CursorAgentPlatformOptions, AgentDefinition, ModelParameterValue } from "@cursor/sdk";
39
39
  import type { CursorMcpServerConfig } from "./mcp-resolver.js";
40
40
  export interface CreateAgentOptions {
41
41
  apiKey: string;
42
42
  model: string;
43
+ /**
44
+ * Explicit variant parameters sent with the model selection on every
45
+ * create AND resume (stigmer/stigmer#357). A bare `{ id }` lets the
46
+ * Cursor catalog's default variant pick the price, so the caller always
47
+ * supplies the pinned params from resolveServiceTierParams — possibly
48
+ * empty (Auto, or a model with no price-bearing parameters), but never
49
+ * absent by accident.
50
+ */
51
+ modelParams?: ModelParameterValue[];
43
52
  workspaceDirs: string[];
44
53
  sessionId: string;
45
54
  /** Durable workspace volume root; the SDK state store lives under it. */
@@ -68,6 +77,8 @@ export interface ResumeAgentOptions {
68
77
  /** Durable workspace volume root; the SDK state store lives under it. */
69
78
  workspaceRootDir: string;
70
79
  model?: string;
80
+ /** Explicit variant parameters — see {@link CreateAgentOptions.modelParams}. */
81
+ modelParams?: ModelParameterValue[];
71
82
  mcpServers?: Record<string, CursorMcpServerConfig>;
72
83
  /** Custom sub-agents — see {@link CreateAgentOptions.agents}. */
73
84
  agents?: Record<string, AgentDefinition>;
@@ -79,6 +90,8 @@ export interface CloudRepo {
79
90
  export interface CreateCloudAgentOptions {
80
91
  apiKey: string;
81
92
  model?: string;
93
+ /** Explicit variant parameters — see {@link CreateAgentOptions.modelParams}. */
94
+ modelParams?: ModelParameterValue[];
82
95
  repos: CloudRepo[];
83
96
  sessionId: string;
84
97
  mcpServers?: Record<string, CursorMcpServerConfig>;
@@ -89,6 +102,8 @@ export interface ResumeCloudAgentOptions {
89
102
  apiKey: string;
90
103
  agentId: string;
91
104
  model?: string;
105
+ /** Explicit variant parameters — see {@link CreateAgentOptions.modelParams}. */
106
+ modelParams?: ModelParameterValue[];
92
107
  mcpServers?: Record<string, CursorMcpServerConfig>;
93
108
  /** Custom sub-agents — see {@link CreateAgentOptions.agents}. */
94
109
  agents?: Record<string, AgentDefinition>;
@@ -122,7 +122,9 @@ export async function createAgent(options) {
122
122
  `stateRoot=${platform.stateRoot}, process.cwd=${process.cwd()}`);
123
123
  return Agent.create({
124
124
  apiKey: options.apiKey,
125
- model: { id: options.model },
125
+ // Always a full selection — id AND params. A bare { id } would let the
126
+ // catalog's default variant (account-influenced) pick the price (#357).
127
+ model: { id: options.model, params: options.modelParams },
126
128
  local: { cwd, settingSources: [...LOCAL_SETTING_SOURCES] },
127
129
  mcpServers: options.mcpServers,
128
130
  agents: options.agents,
@@ -145,7 +147,11 @@ export async function resumeAgent(options) {
145
147
  `process.cwd=${process.cwd()}`);
146
148
  return Agent.resume(options.agentId, {
147
149
  apiKey: options.apiKey,
148
- model: options.model ? { id: options.model } : undefined,
150
+ // Variant params must be re-supplied on resume exactly like mcpServers:
151
+ // explicit params hold across resume (verified against the billing
152
+ // ledger, #357), but an id-only resume would fall back to the catalog
153
+ // default variant for the new turns.
154
+ model: options.model ? { id: options.model, params: options.modelParams } : undefined,
149
155
  // Neither cwd nor settingSources survive Agent.resume(); both must be
150
156
  // re-supplied every turn. Omitting cwd makes the SDK fall back to
151
157
  // process.cwd(), which re-roots the agent in the runner's own working
@@ -174,7 +180,7 @@ export async function createCloudAgent(options) {
174
180
  `repos=${options.repos.map((r) => r.url).join(", ")}`);
175
181
  return Agent.create({
176
182
  apiKey: options.apiKey,
177
- model: options.model ? { id: options.model } : undefined,
183
+ model: options.model ? { id: options.model, params: options.modelParams } : undefined,
178
184
  cloud: { repos: options.repos },
179
185
  mcpServers: options.mcpServers,
180
186
  agents: options.agents,
@@ -191,7 +197,7 @@ export async function resumeCloudAgent(options) {
191
197
  console.log(`resumeCloudAgent: agentId=${options.agentId}`);
192
198
  return Agent.resume(options.agentId, {
193
199
  apiKey: options.apiKey,
194
- model: options.model ? { id: options.model } : undefined,
200
+ model: options.model ? { id: options.model, params: options.modelParams } : undefined,
195
201
  mcpServers: options.mcpServers,
196
202
  agents: options.agents,
197
203
  });
@@ -229,6 +235,7 @@ export async function resolveAgent(harnessStateId, options, mode = "local") {
229
235
  apiKey: options.apiKey,
230
236
  agentId: harnessStateId,
231
237
  model: options.model,
238
+ modelParams: options.modelParams,
232
239
  mcpServers: options.mcpServers,
233
240
  agents: options.agents,
234
241
  })
@@ -239,6 +246,7 @@ export async function resolveAgent(harnessStateId, options, mode = "local") {
239
246
  workspaceDirs: options.workspaceDirs,
240
247
  workspaceRootDir: options.workspaceRootDir,
241
248
  model: options.model,
249
+ modelParams: options.modelParams,
242
250
  mcpServers: options.mcpServers,
243
251
  agents: options.agents,
244
252
  });
@@ -1 +1 @@
1
- {"version":3,"file":"session-lifecycle.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/session-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;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CAAC"}
1
+ {"version":3,"file":"session-lifecycle.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/session-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAOpC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGzE,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,qBAAqB,GAAG,CAAC,SAAS,CAAU,CAAC;AAuHnD,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAAiB,EACjB,gBAAwB;IAExB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,8EAA8E;YAC9E,kFAAkF;YAClF,gFAAgF,CACjF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,iFAAiF;YACjF,gFAAgF,CACjF,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,SAAS,CAAC,CAAC;IAC1E,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,OAAO;QACL,YAAY,EAAE,mBAAmB,SAAS,EAAE;QAC5C,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAA2B;IAC3D,MAAM,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B,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAe,EAAE,MAAc;IAChE,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV,kCAAkC,OAAO,GAAG,EAC5C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CACzC,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -12,6 +12,8 @@
12
12
  * BiDi proxy (CursorBidiStreamHandler) which will record usage from the
13
13
  * wire via ProxyUsageReporter once traffic routing (Task 5B) is complete.
14
14
  */
15
+ import type { ModelParameterValue } from "@cursor/sdk";
16
+ import { ServiceTier } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
15
17
  export interface TurnUsage {
16
18
  readonly inputTokens?: number;
17
19
  readonly outputTokens?: number;
@@ -28,6 +30,10 @@ export interface UsageSnapshot {
28
30
  readonly estimatedCostUsd: number;
29
31
  readonly model: string;
30
32
  readonly observedAt: string;
33
+ /** Tier the runner requested — always explicit post-translation (#357). */
34
+ readonly requestedServiceTier: ServiceTier;
35
+ /** JSON-encoded ModelSelection.params the runner sent; "" when none. */
36
+ readonly requestedModelParams: string;
31
37
  }
32
38
  export interface TurnRecord {
33
39
  readonly sequence: number;
@@ -38,6 +44,12 @@ export interface TurnRecord {
38
44
  }
39
45
  export declare class UsageAccumulator {
40
46
  private readonly model;
47
+ /**
48
+ * The explicit tier the runner requested from the provider. Recorded
49
+ * verbatim into status as the audit trail that the account default was
50
+ * never left in control (#357).
51
+ */
52
+ private readonly requestedServiceTier;
41
53
  private inputTokens;
42
54
  private outputTokens;
43
55
  private cacheReadTokens;
@@ -46,7 +58,15 @@ export declare class UsageAccumulator {
46
58
  private estimatedCostUsd;
47
59
  private observedAt;
48
60
  private readonly turnRecords;
49
- constructor(model: string);
61
+ /** JSON-encoded params the runner sent with the model selection (#357). */
62
+ private readonly requestedModelParams;
63
+ constructor(model: string,
64
+ /**
65
+ * The explicit tier the runner requested from the provider. Recorded
66
+ * verbatim into status as the audit trail that the account default was
67
+ * never left in control (#357).
68
+ */
69
+ requestedServiceTier?: ServiceTier, requestedModelParams?: readonly ModelParameterValue[]);
50
70
  addTurn(usage: TurnUsage): void;
51
71
  get hasTurns(): boolean;
52
72
  get modelName(): string;
@@ -12,7 +12,8 @@
12
12
  * BiDi proxy (CursorBidiStreamHandler) which will record usage from the
13
13
  * wire via ProxyUsageReporter once traffic routing (Task 5B) is complete.
14
14
  */
15
- import { getCursorModelPricing, computeTurnCost } from "./model-pricing.js";
15
+ import { ServiceTier } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
16
+ import { getCursorModelPricingForVariant, computeTurnCost } from "./model-pricing.js";
16
17
  const EMPTY_SNAPSHOT = {
17
18
  inputTokens: 0n,
18
19
  outputTokens: 0n,
@@ -23,9 +24,12 @@ const EMPTY_SNAPSHOT = {
23
24
  estimatedCostUsd: 0,
24
25
  model: "",
25
26
  observedAt: "",
27
+ requestedServiceTier: ServiceTier.UNSPECIFIED,
28
+ requestedModelParams: "",
26
29
  };
27
30
  export class UsageAccumulator {
28
31
  model;
32
+ requestedServiceTier;
29
33
  inputTokens = 0;
30
34
  outputTokens = 0;
31
35
  cacheReadTokens = 0;
@@ -34,8 +38,19 @@ export class UsageAccumulator {
34
38
  estimatedCostUsd = 0;
35
39
  observedAt = "";
36
40
  turnRecords = [];
37
- constructor(model) {
41
+ /** JSON-encoded params the runner sent with the model selection (#357). */
42
+ requestedModelParams;
43
+ constructor(model,
44
+ /**
45
+ * The explicit tier the runner requested from the provider. Recorded
46
+ * verbatim into status as the audit trail that the account default was
47
+ * never left in control (#357).
48
+ */
49
+ requestedServiceTier = ServiceTier.UNSPECIFIED, requestedModelParams = []) {
38
50
  this.model = model;
51
+ this.requestedServiceTier = requestedServiceTier;
52
+ this.requestedModelParams =
53
+ requestedModelParams.length > 0 ? JSON.stringify(requestedModelParams) : "";
39
54
  }
40
55
  addTurn(usage) {
41
56
  const input = usage.inputTokens ?? 0;
@@ -55,7 +70,10 @@ export class UsageAccumulator {
55
70
  cacheReadTokens: cacheRead,
56
71
  cacheWriteTokens: cacheWrite,
57
72
  });
58
- const pricing = getCursorModelPricing(this.model);
73
+ // Estimate at the rates of the variant we explicitly requested — a
74
+ // FAST run priced at base rates would understate the display estimate
75
+ // ~4x relative to the authoritative bill (#357).
76
+ const pricing = getCursorModelPricingForVariant(this.model, this.requestedServiceTier === ServiceTier.FAST ? "fast" : null);
59
77
  this.estimatedCostUsd += computeTurnCost(pricing, input, output, cacheWrite, cacheRead);
60
78
  }
61
79
  get hasTurns() {
@@ -85,6 +103,8 @@ export class UsageAccumulator {
85
103
  estimatedCostUsd: this.estimatedCostUsd,
86
104
  model: this.model,
87
105
  observedAt: this.observedAt,
106
+ requestedServiceTier: this.requestedServiceTier,
107
+ requestedModelParams: this.requestedModelParams,
88
108
  };
89
109
  }
90
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"usage-accumulator.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/usage-accumulator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAqB5E,MAAM,cAAc,GAAkB;IACpC,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,EAAE;IAChB,eAAe,EAAE,EAAE;IACnB,gBAAgB,EAAE,EAAE;IACpB,WAAW,EAAE,EAAE;IACf,SAAS,EAAE,CAAC;IACZ,gBAAgB,EAAE,CAAC;IACnB,KAAK,EAAE,EAAE;IACT,UAAU,EAAE,EAAE;CACf,CAAC;AAUF,MAAM,OA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U,EAAE,SAAS,CAC9C,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC;YAAE,OAAO,cAAc,CAAC;QAEhD,OAAO;YACL,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;YACrC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;YACvC,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;YAC7C,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC;YAC/C,qEAAqE;YACrE,qEAAqE;YACrE,uEAAuE;YACvE,mEAAmE;YACnE,mEAAmE;YACnE,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;YACzD,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"usage-accumulator.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/usage-accumulator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAE3F,OAAO,EAAE,+BAA+B,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAyBtF,MAAM,cAAc,GAAkB;IACpC,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,EAAE;IAChB,eAAe,EAAE,EAAE;IACnB,gBAAgB,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E;YACrE,qEAAqE;YACrE,uEAAuE;YACvE,mEAAmE;YACnE,mEAAmE;YACnE,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;YACzD,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;YAC/C,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;SAChD,CAAC;IACJ,CAAC;CACF"}
@@ -63,7 +63,10 @@ export interface RunnerScopedToken {
63
63
  * `poolClaimSessionId` is the warm-pool attach exchange: a pool sandbox
64
64
  * presenting its pool_sandbox credential for the session it was claimed for
65
65
  * (the server authorizes against the claim record, not the caller's FGA
66
- * relations). The execution arms remain embedded_runner-only.
66
+ * relations). `renewal` is a live sandbox extending its own credential
67
+ * before expiry: no id is named because every mint parameter comes from the
68
+ * presented credential's verified claims (see sandbox-token-renewal.ts).
69
+ * The execution arms remain embedded_runner-only.
67
70
  */
68
71
  export type RunnerScopedTokenScope = {
69
72
  agentExecutionId: string;
@@ -71,6 +74,8 @@ export type RunnerScopedTokenScope = {
71
74
  workflowExecutionId: string;
72
75
  } | {
73
76
  poolClaimSessionId: string;
77
+ } | {
78
+ renewal: true;
74
79
  };
75
80
  /**
76
81
  * A shared mutable token reference. When provided, the interceptor
@@ -32,7 +32,7 @@ import { WorkflowExecutionQueryController } from "@stigmer/protos/ai/stigmer/age
32
32
  import { WorkflowExecutionUpdateStatusInputSchema, GetEventLogRequestSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/io_pb";
33
33
  import { WorkflowQueryController } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/query_pb";
34
34
  import { WorkflowInstanceQueryController } from "@stigmer/protos/ai/stigmer/agentic/workflowinstance/v1/query_pb";
35
- import { PlatformQueryController, GetRunnerScopedTokenInputSchema } from "@stigmer/protos/ai/stigmer/platform/v1/server_info_pb";
35
+ import { PlatformQueryController, GetRunnerScopedTokenInputSchema, TokenRenewalSchema } from "@stigmer/protos/ai/stigmer/platform/v1/server_info_pb";
36
36
  import { ChannelMessageQueryController } from "@stigmer/protos/ai/stigmer/agentic/agentchannel/v1/message_query_pb";
37
37
  import { isEmbeddedRunnerToken } from "./token-claims.js";
38
38
  import { assertCreateRequirements, assertReferenceRequirements } from "./server-contracts.js";
@@ -48,7 +48,10 @@ function toRunnerScopedTokenOneof(scope) {
48
48
  if ("workflowExecutionId" in scope) {
49
49
  return { case: "workflowExecutionId", value: scope.workflowExecutionId };
50
50
  }
51
- return { case: "poolClaim", value: { sessionId: scope.poolClaimSessionId } };
51
+ if ("poolClaimSessionId" in scope) {
52
+ return { case: "poolClaim", value: { sessionId: scope.poolClaimSessionId } };
53
+ }
54
+ return { case: "renewal", value: create(TokenRenewalSchema) };
52
55
  }
53
56
  export class StigmerClient {
54
57
  transport;