@stigmer/server 3.15.3-dev.20260916211208 → 3.16.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 (152) hide show
  1. package/dist/authorization/lane-admission.d.ts +50 -0
  2. package/dist/authorization/lane-admission.d.ts.map +1 -0
  3. package/dist/authorization/lane-admission.js +13 -0
  4. package/dist/authorization/lane-admission.js.map +1 -0
  5. package/dist/authorization/schedule-fire-caller.d.ts +2 -2
  6. package/dist/authorization/schedule-fire-caller.d.ts.map +1 -1
  7. package/dist/authorization/schedule-fire-caller.js +8 -8
  8. package/dist/authorization/schedule-fire-caller.js.map +1 -1
  9. package/dist/boot/compose.d.ts.map +1 -1
  10. package/dist/boot/compose.js +66 -14
  11. package/dist/boot/compose.js.map +1 -1
  12. package/dist/boot/inprocess.d.ts.map +1 -1
  13. package/dist/boot/inprocess.js +6 -1
  14. package/dist/boot/inprocess.js.map +1 -1
  15. package/dist/domain/executioncontext/resolve-values-for-caller.d.ts +33 -14
  16. package/dist/domain/executioncontext/resolve-values-for-caller.d.ts.map +1 -1
  17. package/dist/domain/executioncontext/resolve-values-for-caller.js +32 -8
  18. package/dist/domain/executioncontext/resolve-values-for-caller.js.map +1 -1
  19. package/dist/domain/identityaccount/actor.d.ts +33 -18
  20. package/dist/domain/identityaccount/actor.d.ts.map +1 -1
  21. package/dist/domain/identityaccount/actor.js +20 -3
  22. package/dist/domain/identityaccount/actor.js.map +1 -1
  23. package/dist/domain/identityaccount/resolve.d.ts +19 -0
  24. package/dist/domain/identityaccount/resolve.d.ts.map +1 -1
  25. package/dist/domain/identityaccount/resolve.js +12 -0
  26. package/dist/domain/identityaccount/resolve.js.map +1 -1
  27. package/dist/domain/mcpserver/connect-execution-id.d.ts +5 -0
  28. package/dist/domain/mcpserver/connect-execution-id.d.ts.map +1 -0
  29. package/dist/domain/mcpserver/connect-execution-id.js +32 -0
  30. package/dist/domain/mcpserver/connect-execution-id.js.map +1 -0
  31. package/dist/domain/mcpserver/connect.d.ts +28 -2
  32. package/dist/domain/mcpserver/connect.d.ts.map +1 -1
  33. package/dist/domain/mcpserver/connect.js +27 -7
  34. package/dist/domain/mcpserver/connect.js.map +1 -1
  35. package/dist/domain/mcpserver/engine.d.ts +9 -3
  36. package/dist/domain/mcpserver/engine.d.ts.map +1 -1
  37. package/dist/domain/mcpserver/engine.js.map +1 -1
  38. package/dist/domain/mcpserver/start-connect.js +1 -1
  39. package/dist/domain/mcpserver/start-connect.js.map +1 -1
  40. package/dist/domain/platform/controller.d.ts +24 -11
  41. package/dist/domain/platform/controller.d.ts.map +1 -1
  42. package/dist/domain/platform/controller.js.map +1 -1
  43. package/dist/domain/plugin/overlay/sanitize.d.ts.map +1 -1
  44. package/dist/domain/plugin/overlay/sanitize.js +4 -2
  45. package/dist/domain/plugin/overlay/sanitize.js.map +1 -1
  46. package/dist/domain/workflowexecution/phases.d.ts +21 -0
  47. package/dist/domain/workflowexecution/phases.d.ts.map +1 -0
  48. package/dist/domain/workflowexecution/phases.js +31 -0
  49. package/dist/domain/workflowexecution/phases.js.map +1 -0
  50. package/dist/identity/oidc-verifier.js +8 -1
  51. package/dist/identity/oidc-verifier.js.map +1 -1
  52. package/dist/pipeline/apiresource-meta.d.ts +15 -0
  53. package/dist/pipeline/apiresource-meta.d.ts.map +1 -1
  54. package/dist/pipeline/apiresource-meta.js +34 -0
  55. package/dist/pipeline/apiresource-meta.js.map +1 -1
  56. package/dist/pipeline/steps/guard-memory-capture.d.ts.map +1 -1
  57. package/dist/pipeline/steps/guard-memory-capture.js +5 -3
  58. package/dist/pipeline/steps/guard-memory-capture.js.map +1 -1
  59. package/dist/runnerauth/bound-execution.d.ts +27 -0
  60. package/dist/runnerauth/bound-execution.d.ts.map +1 -0
  61. package/dist/runnerauth/bound-execution.js +137 -0
  62. package/dist/runnerauth/bound-execution.js.map +1 -0
  63. package/dist/runnerauth/built-in-runner-credential-provider.d.ts +28 -0
  64. package/dist/runnerauth/built-in-runner-credential-provider.d.ts.map +1 -0
  65. package/dist/runnerauth/built-in-runner-credential-provider.js +217 -0
  66. package/dist/runnerauth/built-in-runner-credential-provider.js.map +1 -0
  67. package/dist/runnerauth/constants.d.ts +63 -0
  68. package/dist/runnerauth/constants.d.ts.map +1 -0
  69. package/dist/runnerauth/constants.js +63 -0
  70. package/dist/runnerauth/constants.js.map +1 -0
  71. package/dist/runnerauth/dispatch-credential.d.ts +38 -0
  72. package/dist/runnerauth/dispatch-credential.d.ts.map +1 -0
  73. package/dist/runnerauth/dispatch-credential.js +17 -0
  74. package/dist/runnerauth/dispatch-credential.js.map +1 -0
  75. package/dist/runnerauth/runner-credential-provider.d.ts +49 -11
  76. package/dist/runnerauth/runner-credential-provider.d.ts.map +1 -1
  77. package/dist/runnerauth/runner-credential-provider.js +16 -4
  78. package/dist/runnerauth/runner-credential-provider.js.map +1 -1
  79. package/dist/runnerauth/runner-subject-verifier.d.ts +14 -0
  80. package/dist/runnerauth/runner-subject-verifier.d.ts.map +1 -0
  81. package/dist/runnerauth/runner-subject-verifier.js +115 -0
  82. package/dist/runnerauth/runner-subject-verifier.js.map +1 -0
  83. package/dist/runnerauth/runnerauth.d.ts +33 -4
  84. package/dist/runnerauth/runnerauth.d.ts.map +1 -1
  85. package/dist/runnerauth/runnerauth.js +131 -35
  86. package/dist/runnerauth/runnerauth.js.map +1 -1
  87. package/dist/temporal/agentexecution/engine-client.d.ts +13 -0
  88. package/dist/temporal/agentexecution/engine-client.d.ts.map +1 -1
  89. package/dist/temporal/agentexecution/engine-client.js +10 -2
  90. package/dist/temporal/agentexecution/engine-client.js.map +1 -1
  91. package/dist/temporal/agentexecution/workflow-input.d.ts +13 -0
  92. package/dist/temporal/agentexecution/workflow-input.d.ts.map +1 -1
  93. package/dist/temporal/agentexecution/workflows/invoke-agent-execution.d.ts.map +1 -1
  94. package/dist/temporal/agentexecution/workflows/invoke-agent-execution.js +35 -31
  95. package/dist/temporal/agentexecution/workflows/invoke-agent-execution.js.map +1 -1
  96. package/dist/temporal/workflowexecution/engine-client.d.ts +24 -0
  97. package/dist/temporal/workflowexecution/engine-client.d.ts.map +1 -1
  98. package/dist/temporal/workflowexecution/engine-client.js +26 -19
  99. package/dist/temporal/workflowexecution/engine-client.js.map +1 -1
  100. package/dist/temporal/workflowexecution/workflow-input.d.ts +14 -0
  101. package/dist/temporal/workflowexecution/workflow-input.d.ts.map +1 -1
  102. package/package.json +5 -5
  103. package/src/authorization/__tests__/lane-admission.test.ts +115 -0
  104. package/src/authorization/lane-admission.ts +73 -0
  105. package/src/authorization/schedule-fire-caller.ts +10 -14
  106. package/src/boot/compose.ts +79 -22
  107. package/src/boot/inprocess.ts +7 -1
  108. package/src/domain/executioncontext/__tests__/executioncontext.test.ts +104 -0
  109. package/src/domain/executioncontext/__tests__/resolve-values-capability.test.ts +33 -4
  110. package/src/domain/executioncontext/resolve-values-for-caller.ts +79 -22
  111. package/src/domain/identityaccount/__tests__/account-for-stamp.test.ts +111 -0
  112. package/src/domain/identityaccount/actor.ts +61 -21
  113. package/src/domain/identityaccount/resolve.ts +31 -0
  114. package/src/domain/mcpserver/__tests__/connect.test.ts +17 -2
  115. package/src/domain/mcpserver/connect-execution-id.ts +34 -0
  116. package/src/domain/mcpserver/connect.ts +38 -3
  117. package/src/domain/mcpserver/engine.ts +9 -3
  118. package/src/domain/mcpserver/start-connect.ts +1 -1
  119. package/src/domain/platform/controller.ts +24 -11
  120. package/src/domain/plugin/__tests__/plugin.test.ts +116 -1
  121. package/src/domain/plugin/__tests__/sanitize.test.ts +2 -2
  122. package/src/domain/plugin/overlay/sanitize.ts +4 -2
  123. package/src/domain/workflowexecution/__tests__/phases.test.ts +58 -0
  124. package/src/domain/workflowexecution/phases.ts +33 -0
  125. package/src/extensions/__tests__/extension-composition.test.ts +7 -1
  126. package/src/identity/__tests__/oidc-verifier.test.ts +22 -0
  127. package/src/identity/oidc-verifier.ts +8 -1
  128. package/src/pipeline/__tests__/kind-by-id-prefix.test.ts +75 -0
  129. package/src/pipeline/apiresource-meta.ts +41 -0
  130. package/src/pipeline/steps/__tests__/guard-memory-capture.test.ts +55 -35
  131. package/src/pipeline/steps/guard-memory-capture.ts +5 -3
  132. package/src/runnerauth/__tests__/bound-execution.test.ts +334 -0
  133. package/src/runnerauth/__tests__/built-in-runner-credential-provider.test.ts +516 -0
  134. package/src/runnerauth/__tests__/dispatch-credential.test.ts +94 -0
  135. package/src/runnerauth/__tests__/runner-credential-provider.test.ts +27 -0
  136. package/src/runnerauth/__tests__/runner-subject-composed.test.ts +497 -0
  137. package/src/runnerauth/__tests__/runner-subject-verifier.test.ts +541 -0
  138. package/src/runnerauth/bound-execution.ts +270 -0
  139. package/src/runnerauth/built-in-runner-credential-provider.ts +300 -0
  140. package/src/runnerauth/constants.ts +74 -0
  141. package/src/runnerauth/dispatch-credential.ts +63 -0
  142. package/src/runnerauth/runner-credential-provider.ts +60 -11
  143. package/src/runnerauth/runner-subject-verifier.ts +152 -0
  144. package/src/runnerauth/runnerauth.ts +148 -38
  145. package/src/temporal/agentexecution/__tests__/engine-client.test.ts +107 -38
  146. package/src/temporal/agentexecution/__tests__/invoke-workflow.test.ts +105 -2
  147. package/src/temporal/agentexecution/engine-client.ts +27 -2
  148. package/src/temporal/agentexecution/workflow-input.ts +13 -0
  149. package/src/temporal/agentexecution/workflows/invoke-agent-execution.ts +90 -44
  150. package/src/temporal/workflowexecution/__tests__/engine-client.test.ts +139 -33
  151. package/src/temporal/workflowexecution/engine-client.ts +48 -21
  152. package/src/temporal/workflowexecution/workflow-input.ts +14 -0
@@ -0,0 +1,137 @@
1
+ import { AgentExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
2
+ import { ExecutionContextSchema } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/api_pb";
3
+ import { WorkflowExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
4
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
5
+ import { isTerminalExecutionPhase } from "../domain/agentexecution/phases.js";
6
+ import { isConnectExecutionId } from "../domain/mcpserver/connect-execution-id.js";
7
+ import { isTerminalWorkflowExecutionPhase } from "../domain/workflowexecution/phases.js";
8
+ import { kindByIdPrefix } from "../pipeline/apiresource-meta.js";
9
+ import { auditOf } from "../pipeline/steps/defaults.js";
10
+ import { ResourceNotFoundError } from "../store/interface.js";
11
+ import { RUN_CREDENTIAL_GRACE_AFTER_TERMINAL_MS } from "./constants.js";
12
+ export function boundExecutionKindOf(executionId) {
13
+ switch (kindByIdPrefix(executionId)) {
14
+ case ApiResourceKind.agent_execution:
15
+ return "agent-execution";
16
+ case ApiResourceKind.workflow_execution:
17
+ return "workflow-execution";
18
+ default:
19
+ return isConnectExecutionId(executionId) ? "mcp-connect" : undefined;
20
+ }
21
+ }
22
+ /** Whether a binding of this kind is a RUN — the only thing a no-`exp` credential may name (see the header). */
23
+ export function bindsARun(kind) {
24
+ switch (kind) {
25
+ case "agent-execution":
26
+ case "workflow-execution":
27
+ return true;
28
+ case "mcp-connect":
29
+ return false;
30
+ default: {
31
+ const exhaustive = kind;
32
+ throw new Error(`unknown bound execution kind ${String(exhaustive)}`);
33
+ }
34
+ }
35
+ }
36
+ /**
37
+ * Loads the bound execution's facts; `undefined` when the id names no
38
+ * binding kind or no row. `now` is injectable for the grace arms and
39
+ * defaults to the wall clock.
40
+ */
41
+ export async function loadBoundExecution(store, executionId, now = Date.now()) {
42
+ const kind = boundExecutionKindOf(executionId);
43
+ if (kind === undefined) {
44
+ return undefined;
45
+ }
46
+ switch (kind) {
47
+ case "agent-execution": {
48
+ const row = await getRow(store, ApiResourceKind.agent_execution, executionId, AgentExecutionSchema);
49
+ if (row === undefined) {
50
+ return undefined;
51
+ }
52
+ return {
53
+ kind,
54
+ executionId,
55
+ org: row.metadata?.org ?? "",
56
+ createdBy: creatorStampOf(AgentExecutionSchema, row),
57
+ sessionId: row.spec?.sessionId ?? "",
58
+ live: isLive(row.status !== undefined &&
59
+ isTerminalExecutionPhase(row.status.phase), row.status?.completedAt ?? "", now),
60
+ };
61
+ }
62
+ case "workflow-execution": {
63
+ const row = await getRow(store, ApiResourceKind.workflow_execution, executionId, WorkflowExecutionSchema);
64
+ if (row === undefined) {
65
+ return undefined;
66
+ }
67
+ return {
68
+ kind,
69
+ executionId,
70
+ org: row.metadata?.org ?? "",
71
+ createdBy: creatorStampOf(WorkflowExecutionSchema, row),
72
+ sessionId: "",
73
+ live: isLive(row.status !== undefined &&
74
+ isTerminalWorkflowExecutionPhase(row.status.phase), row.status?.completedAt ?? "", now),
75
+ };
76
+ }
77
+ case "mcp-connect": {
78
+ // The connect's ExecutionContext, by the execution id it was
79
+ // created for — the same indexed read getByExecutionId makes. The
80
+ // row is deleted when the connect settles, so its presence is the
81
+ // liveness; the token's clock is enforced by `verify` before this.
82
+ const row = await getExecutionContextRow(store, executionId);
83
+ if (row === undefined) {
84
+ return undefined;
85
+ }
86
+ return {
87
+ kind,
88
+ executionId,
89
+ org: row.metadata?.org ?? "",
90
+ createdBy: creatorStampOf(ExecutionContextSchema, row),
91
+ sessionId: "",
92
+ live: true,
93
+ };
94
+ }
95
+ default: {
96
+ const exhaustive = kind;
97
+ throw new Error(`unknown bound execution kind ${String(exhaustive)}`);
98
+ }
99
+ }
100
+ }
101
+ /** A row with no status has not started, which is live. */
102
+ function isLive(terminal, completedAt, now) {
103
+ if (!terminal) {
104
+ return true;
105
+ }
106
+ const finishedAt = Date.parse(completedAt);
107
+ if (Number.isNaN(finishedAt)) {
108
+ return false;
109
+ }
110
+ return now - finishedAt < RUN_CREDENTIAL_GRACE_AFTER_TERMINAL_MS;
111
+ }
112
+ function creatorStampOf(schema, row) {
113
+ return auditOf(schema, row)?.specAudit?.createdBy?.id ?? "";
114
+ }
115
+ async function getRow(store, kind, id, schema) {
116
+ try {
117
+ return await store.getResource(kind, id, schema);
118
+ }
119
+ catch (error) {
120
+ if (error instanceof ResourceNotFoundError) {
121
+ return undefined;
122
+ }
123
+ throw error;
124
+ }
125
+ }
126
+ async function getExecutionContextRow(store, executionId) {
127
+ try {
128
+ return await store.findByField(ApiResourceKind.execution_context, "spec.executionId", executionId, ExecutionContextSchema);
129
+ }
130
+ catch (error) {
131
+ if (error instanceof ResourceNotFoundError) {
132
+ return undefined;
133
+ }
134
+ throw error;
135
+ }
136
+ }
137
+ //# sourceMappingURL=bound-execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bound-execution.js","sourceRoot":"","sources":["../../src/runnerauth/bound-execution.ts"],"names":[],"mappings":"AAiEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AACnG,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AACvG,OAAO,EAAE,uBAAuB,EAAE,MAAM,gEAAgE,CAAC;AACzG,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAEtH,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AACnF,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,sCAAsC,EAAE,MAAM,gBAAgB,CAAC;AAwBxE,MAAM,UAAU,oBAAoB,CAClC,WAAmB;IAEnB,QAAQ,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;QACpC,KAAK,eAAe,CAAC,eAAe;YAClC,OAAO,iBAAiB,CAAC;QAC3B,KAAK,eAAe,CAAC,kBAAkB;YACrC,OAAO,oBAAoB,CAAC;QAC9B;YACE,OAAO,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,aAAa,CA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;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,qBAAqB,EAAE,CAAC;YAC3C,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { AccountsByCaller } from "../domain/identityaccount/resolve.js";
2
+ import type { CallerIdentity } from "../extensions/identity.js";
3
+ import type { BoundExecutionKind, BoundExecutionStore } from "./bound-execution.js";
4
+ import type { RunnerCredentialProvider } from "./runner-credential-provider.js";
5
+ import type { RunnerAuthService } from "./runnerauth.js";
6
+ /** What a runner-class caller's credential is bound to. */
7
+ export interface RunnerBinding {
8
+ readonly kind: BoundExecutionKind;
9
+ readonly executionId: string;
10
+ }
11
+ export interface BuiltInRunnerCredentialProviderDeps {
12
+ /** The service that signed every token this provider reads. */
13
+ readonly service: RunnerAuthService;
14
+ /** Where the bound executions live — the capture and exchange capabilities' one read each. */
15
+ readonly store: BoundExecutionStore;
16
+ /** Resolves a run's creator stamp to its person — the exchange's owner check, the verifier's reading. */
17
+ readonly accounts: AccountsByCaller;
18
+ }
19
+ /**
20
+ * The one reading of a runner's binding. `undefined` for anything that
21
+ * is not a runner-class caller holding a token this service signed whose
22
+ * binding names an execution kind; never a throw.
23
+ */
24
+ export declare function runnerBindingOf(service: RunnerAuthService, caller: CallerIdentity): RunnerBinding | undefined;
25
+ /** The lane-admission predicate: a runner acting for a WORKFLOW execution (the cloud's `workflow_sandbox`). */
26
+ export declare function isWorkflowBoundRunner(service: RunnerAuthService, caller: CallerIdentity): boolean;
27
+ export declare function newBuiltInRunnerCredentialProvider(deps: BuiltInRunnerCredentialProviderDeps): RunnerCredentialProvider;
28
+ //# sourceMappingURL=built-in-runner-credential-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"built-in-runner-credential-provider.d.ts","sourceRoot":"","sources":["../../src/runnerauth/built-in-runner-credential-provider.ts"],"names":[],"mappings":"AAkGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAQhE,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EAEV,wBAAwB,EAGzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,mCAAmC;IAClD,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,yGAAyG;IACzG,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,cAAc,GACrB,aAAa,GAAG,SAAS,CAY3B;AAED,+GAA+G;AAC/G,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,cAAc,GACrB,OAAO,CAET;AAkBD,wBAAgB,kCAAkC,CAChD,IAAI,EAAE,mCAAmC,GACxC,wBAAwB,CA+G1B"}
@@ -0,0 +1,217 @@
1
+ /**
2
+ * The built-in RunnerCredentialProvider — the open-source execution-scoped
3
+ * default (runner-credential-provider.ts) plus the three capabilities an
4
+ * ENFORCING self-host needs, composed under the built-in authorization
5
+ * posture beside the runner-subject verifier (boot/compose.ts). The
6
+ * cloud's shape, kept on purpose: one provider object carries the
7
+ * edition's whole credential story, so the composition root binds one
8
+ * thing and every OSS touchpoint that consults the seam sees the same
9
+ * policy. Mint, verify, isEnabled and the dispatch's `mintRunCredential`
10
+ * are the default provider's, byte for byte; under trusted-local the
11
+ * default alone is composed and none of what follows exists.
12
+ *
13
+ * ONE reading of "what is this runner bound to" — `runnerBindingOf` —
14
+ * feeds everything here and the Authorizer's lane admission
15
+ * (authorization/lane-admission.ts). It re-verifies the caller's own
16
+ * `rawToken` (the cloud's `verifiedClaims(caller.rawToken)` pattern: one
17
+ * HMAC, no store read) and reads the kind off the bound id's prefix
18
+ * through the contract's table (bound-execution.ts). It checks the
19
+ * caller CLASS first: the lane admission runs on every run-gate check
20
+ * for every caller, and only the runner-subject verifier mints `runner`,
21
+ * so a person costs nothing here. It never throws: a person, a runner
22
+ * holding no token, a token this server did not sign, or a binding that
23
+ * names no kind is simply "not a runner binding", and each caller
24
+ * answers its own default for that. A CONNECT binding (`mcp-connect`, a
25
+ * runner reading one discovery's secrets as the person who asked) IS a
26
+ * runner binding, and every capability below answers it by name: it is
27
+ * admitted on no run gate, vouches no lineage, captures no memory, and
28
+ * the exchange mints nothing for it.
29
+ *
30
+ * The capabilities, and where they follow or narrow the cloud:
31
+ *
32
+ * - `vouchRunnerLineageLabels`: a WORKFLOW-bound runner vouches the two
33
+ * lineage keys for its own workflow execution and REFUSES a stamp
34
+ * naming another (the cloud's byte-pinned copy, constants.ts). Without
35
+ * this, a self-host with sign-in on cannot run any workflow that
36
+ * calls an agent: the child create's GuardReservedLabels asks the
37
+ * Authorizer for `can_write_reserved_labels` on the platform object,
38
+ * which the built-in Authorizer denies for everyone. NARROWER than the
39
+ * cloud on purpose: the cloud vouches for every runner-class
40
+ * credential and binds only its workflow lane; here an agent-bound
41
+ * runner vouches nothing, because the workflow's `agent_call` activity
42
+ * is the only producer of the lineage labels and it runs under the
43
+ * workflow's credential (runner: activities/call-agent.ts). Nothing
44
+ * observable diverges; do not widen this toward the cloud without a
45
+ * producer that needs it.
46
+ * - `authorizeMemoryCapture`: an AGENT-bound runner is ADMITTED with the
47
+ * human the verifier resolved as the memory's subject — the row's one
48
+ * principal under the model; without it every memory an enforcing
49
+ * self-host writes belongs to nobody — and the run's session as the
50
+ * proved provenance. The cloud reads both off its session-scoped
51
+ * token; our token names only the execution, so this reads the row
52
+ * (one primary-key read per `remember` call) and the seam allows the
53
+ * promise. The cloud's org arm is kept: a capture addressed to an org
54
+ * that is not the run's is "a forged address, not a routing choice"
55
+ * (its byte-pinned copy). A workflow-bound runner is refused (the
56
+ * cloud refuses every non-session lane); a person, or a runner whose
57
+ * token does not verify, is no-opinion and the gate's own logic
58
+ * applies. A run that has vanished between the verifier's read and
59
+ * this one is refused: a memory the server cannot attribute to a run
60
+ * must not be written as nobody's (fail closed).
61
+ * - `exchangeScopedToken`: the platform exchange (getRunnerScopedToken)
62
+ * becomes a MINT GATE. Under trusted-local the controller's own arms
63
+ * mint a clocked decrypt-lane token for any caller naming an
64
+ * execution, and that is harmless — the token unlocks a decrypt lane
65
+ * and nothing more. Under this posture the same token IS an identity
66
+ * (the verifier admits its bearer as the run's human), so minting
67
+ * one for another person's run would be impersonation. The execution
68
+ * arms therefore mint only for the run's own person — the account
69
+ * the row's creator stamp resolves to, the same reading the verifier
70
+ * makes — and mint the RUN credential (no `exp`; `expires_in_seconds`
71
+ * 0, the proto default), so under the posture there is one credential
72
+ * shape and the exchange is the runner's true fallback for a dispatch
73
+ * that carried none. The ladder is the platform's own: a row that
74
+ * does not exist → NOT_FOUND with the load-first copy (what a `get`
75
+ * on that id answers), a caller who is not the run's person, or a run
76
+ * whose stamp names nobody → PERMISSION_DENIED with one sentence
77
+ * (constants.ts). The id decides which execution kind is read (the
78
+ * lane's rule everywhere); the request's arm only chooses the
79
+ * not-found copy; an id that resolves to a CONNECT binding is
80
+ * NOT_FOUND too, because the exchange mints run credentials and a
81
+ * connect is not a run. Liveness is NOT judged at mint — both lanes that
82
+ * accept the token judge it, by one rule (bound-execution.ts), and a
83
+ * third judge here would be a divergence waiting to happen. The
84
+ * pool-claim, renewal and unset arms answer not-minted, the
85
+ * controller's arms verbatim; keyless answers not-minted too.
86
+ *
87
+ * Deliberately UNDEFINED here: `bootstrapCredentials`,
88
+ * `mintSandboxCredential`, `authorizeExecutionContextRead`,
89
+ * `resolvePayloadKey`. Their open-source arms stay where they are (the
90
+ * sandbox lane's mint, the decrypt lane's binding-equality decision);
91
+ * this provider adds policy an enforcing server lacks and takes over
92
+ * nothing that already works.
93
+ */
94
+ import { Code, ConnectError } from "@connectrpc/connect";
95
+ import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
96
+ import { accountForStamp } from "../domain/identityaccount/resolve.js";
97
+ import { getKindName } from "../pipeline/apiresource-meta.js";
98
+ import { notFoundError } from "../pipeline/errors.js";
99
+ import { bindsARun, boundExecutionKindOf, loadBoundExecution, } from "./bound-execution.js";
100
+ import { MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE, RUN_CREDENTIAL_NOT_RUNS_PERSON_MESSAGE, WORKFLOW_LINEAGE_BINDING_MISMATCH_MESSAGE, } from "./constants.js";
101
+ import { newExecutionScopedRunnerCredentialProvider } from "./runner-credential-provider.js";
102
+ /**
103
+ * The one reading of a runner's binding. `undefined` for anything that
104
+ * is not a runner-class caller holding a token this service signed whose
105
+ * binding names an execution kind; never a throw.
106
+ */
107
+ export function runnerBindingOf(service, caller) {
108
+ if (caller.callerClass !== "runner" || caller.rawToken === "") {
109
+ return undefined;
110
+ }
111
+ let executionId;
112
+ try {
113
+ executionId = service.verify(caller.rawToken);
114
+ }
115
+ catch {
116
+ return undefined;
117
+ }
118
+ const kind = boundExecutionKindOf(executionId);
119
+ return kind === undefined ? undefined : { kind, executionId };
120
+ }
121
+ /** The lane-admission predicate: a runner acting for a WORKFLOW execution (the cloud's `workflow_sandbox`). */
122
+ export function isWorkflowBoundRunner(service, caller) {
123
+ return runnerBindingOf(service, caller)?.kind === "workflow-execution";
124
+ }
125
+ /** The kind name the not-found copy carries, by the request's arm (what a `get` on that kind would say). */
126
+ function requestedKindName(arm) {
127
+ switch (arm) {
128
+ case "agent-execution":
129
+ return getKindName(ApiResourceKind.agent_execution);
130
+ case "workflow-execution":
131
+ return getKindName(ApiResourceKind.workflow_execution);
132
+ default: {
133
+ const exhaustive = arm;
134
+ throw new Error(`unhandled exchange arm: ${JSON.stringify(exhaustive)}`);
135
+ }
136
+ }
137
+ }
138
+ export function newBuiltInRunnerCredentialProvider(deps) {
139
+ const { service, store, accounts } = deps;
140
+ const lane = newExecutionScopedRunnerCredentialProvider(service);
141
+ const mintRunCredential = lane.mintRunCredential.bind(lane);
142
+ return {
143
+ isEnabled: lane.isEnabled,
144
+ mint: lane.mint,
145
+ verify: lane.verify,
146
+ mintRunCredential,
147
+ async exchangeScopedToken(request, caller) {
148
+ switch (request.arm) {
149
+ case "agent-execution":
150
+ case "workflow-execution": {
151
+ if (request.executionId === "" || !service.isEnabled()) {
152
+ return { minted: false };
153
+ }
154
+ const execution = await loadBoundExecution(store, request.executionId);
155
+ // A connect binding is not a run: the exchange mints RUN
156
+ // credentials, and the requested kind's row does not exist.
157
+ if (execution === undefined || !bindsARun(execution.kind)) {
158
+ throw notFoundError(requestedKindName(request.arm), request.executionId);
159
+ }
160
+ const person = await accountForStamp(accounts, execution.createdBy);
161
+ if (person === undefined ||
162
+ person.metadata?.id !== caller.identityId) {
163
+ throw new ConnectError(RUN_CREDENTIAL_NOT_RUNS_PERSON_MESSAGE, Code.PermissionDenied);
164
+ }
165
+ return {
166
+ minted: true,
167
+ token: mintRunCredential(execution.executionId),
168
+ // No `exp` on a run credential; 0 is the proto default and
169
+ // the runner's acquire sites read no expiry from it.
170
+ expiresInSeconds: 0,
171
+ };
172
+ }
173
+ case "pool-claim":
174
+ case "renewal":
175
+ case "unset":
176
+ return { minted: false };
177
+ default: {
178
+ const exhaustive = request;
179
+ throw new Error(`unhandled exchange arm: ${JSON.stringify(exhaustive)}`);
180
+ }
181
+ }
182
+ },
183
+ vouchRunnerLineageLabels(caller, stampedWorkflowExecutionId) {
184
+ const binding = runnerBindingOf(service, caller);
185
+ if (binding?.kind !== "workflow-execution") {
186
+ return false;
187
+ }
188
+ if (stampedWorkflowExecutionId !== "" &&
189
+ stampedWorkflowExecutionId !== binding.executionId) {
190
+ throw new ConnectError(WORKFLOW_LINEAGE_BINDING_MISMATCH_MESSAGE, Code.InvalidArgument);
191
+ }
192
+ return true;
193
+ },
194
+ async authorizeMemoryCapture(caller, captureOrg) {
195
+ const binding = runnerBindingOf(service, caller);
196
+ if (binding === undefined) {
197
+ return { verdict: "no-opinion" };
198
+ }
199
+ if (binding.kind !== "agent-execution") {
200
+ return { verdict: "refuse" };
201
+ }
202
+ const execution = await loadBoundExecution(store, binding.executionId);
203
+ if (execution === undefined) {
204
+ return { verdict: "refuse" };
205
+ }
206
+ if (captureOrg !== "" && captureOrg !== execution.org) {
207
+ throw new ConnectError(MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE, Code.PermissionDenied);
208
+ }
209
+ return {
210
+ verdict: "admit",
211
+ subjectIdentityAccountId: caller.identityId,
212
+ provedSessionId: execution.sessionId,
213
+ };
214
+ },
215
+ };
216
+ }
217
+ //# sourceMappingURL=built-in-runner-credential-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"built-in-runner-credential-provider.js","sourceRoot":"","sources":["../../src/runnerauth/built-in-runner-credential-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AACH,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AAEtH,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAGvE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAA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,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;YACnC,CAAC;YACD,IAAI,OAAO,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBACvC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC/B,CAAC;YACD,MAAM,SAAS,GAAG,MAAM,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;YACvE,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC5B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC/B,CAAC;YACD,IAAI,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,SAAS,CAAC,GAAG,EAAE,CAAC;gBACtD,MAAM,IAAI,YAAY,CACpB,mCAAmC,EACnC,IAAI,CAAC,gBAAgB,CACtB,CAAC;YACJ,CAAC;YACD,OAAO;gBACL,OAAO,EAAE,OAAO;gBAChB,wBAAwB,EAAE,MAAM,CAAC,UAAU;gBAC3C,eAAe,EAAE,SAAS,CAAC,SAAS;aACrC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The runner-subject lane's pinned names and copy — the one constants
3
+ * module for the runner-credential domain (the ts-server guideline:
4
+ * byte-pinned copy lives in one constants module per domain, never
5
+ * inline at the refusal site).
6
+ *
7
+ * Two refusal sentences for a PRESENTED credential, deliberately not
8
+ * more (the InvalidTokenError doctrine of runnerauth.ts: a finer reason
9
+ * invites branching on it). The runner is the only caller that ever
10
+ * presents a run credential, and the person reading these is its
11
+ * operator, in the runner's log:
12
+ *
13
+ * - the TOKEN sentence: the credential itself is not one this server
14
+ * will honor — forged, the wrong shape, bound to an execution or a
15
+ * connect this server does not have (a connect's row is gone once
16
+ * the connect settles), a clockless token bound to a connect (a shape
17
+ * no mint produces), a present `exp` in the past, or minted by a key
18
+ * this server does not hold. A missing row is this sentence and not
19
+ * NOT_FOUND on purpose: the credential is invalid, and the run is
20
+ * not the caller's to learn about.
21
+ * - the LIVENESS sentence: the credential is genuine but its run is
22
+ * over, or its run or connect was created by nobody this server
23
+ * recognizes as a person (the schedule fire caller's
24
+ * deterministic-refusal shape: no retry will make that run anyone's).
25
+ *
26
+ * And one for a REQUESTED credential — the platform exchange under the
27
+ * built-in posture (built-in-runner-credential-provider.ts), where the
28
+ * caller is a signed-in person asking for a run's credential and the
29
+ * answer is a permission, not a token verdict: only the person whose run
30
+ * it is may hold its credential. A run whose creator stamp names nobody
31
+ * gets the same sentence — no one is its person.
32
+ *
33
+ * The lineage mismatch copy is the cloud edition's, transcribed byte for
34
+ * byte (credentials/provider.ts in the composition; the Java
35
+ * RecordRunnerLineageLabelsStep before it) so the two editions refuse a
36
+ * mis-stamped lineage label with one sentence.
37
+ */
38
+ /** The verifier's name in the boot log and in auth failures (the `oidc` / `apikey` precedent). */
39
+ export declare const RUNNER_VERIFIER_NAME = "runner";
40
+ /** The token arms: forged, wrong shape, unknown execution, past `exp`, keyless. */
41
+ export declare const RUNNER_CREDENTIAL_INVALID_MESSAGE = "runner credential is not valid on this server";
42
+ /** The resolution arms: a terminal execution; a run stamped by nobody the server recognizes. */
43
+ export declare const RUNNER_CREDENTIAL_NOT_LIVE_MESSAGE = "runner credential names a run that is over or belongs to nobody this server recognizes";
44
+ /** The exchange's refusal under the built-in posture: the caller is not the run's person (PERMISSION_DENIED). */
45
+ export declare const RUN_CREDENTIAL_NOT_RUNS_PERSON_MESSAGE = "a run credential is minted only for the person whose run it is";
46
+ /** The cloud's byte-pinned lineage refusal (the Java step's copy). */
47
+ export declare const WORKFLOW_LINEAGE_BINDING_MISMATCH_MESSAGE = "workflow lineage label names a workflow execution this runner credential is not bound to";
48
+ /** The cloud's byte-pinned org-mismatch refusal (MemoryPolicy.MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE). */
49
+ export declare const MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE = "memory capture is scoped to the session's organization";
50
+ /**
51
+ * How long a run credential outlives its run, measured from the row's
52
+ * `status.completed_at`. A run's credential is valid while the run is
53
+ * not terminal — runs wait on humans with no timeout, so no clock can
54
+ * bound them — and for this long after, because two legitimate runner
55
+ * writes land after the terminal stamp: the session-subject generation
56
+ * the workflow fires and does not await (issue #665), and a Temporal
57
+ * activity retried after its completion failed to reach the engine.
58
+ * Ten minutes covers one model call and one retry backoff; today's
59
+ * exchange-lane token outlives a run by up to an hour. A terminal row
60
+ * with no `completed_at` gets no grace: fail closed.
61
+ */
62
+ export declare const RUN_CREDENTIAL_GRACE_AFTER_TERMINAL_MS: number;
63
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/runnerauth/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,kGAAkG;AAClG,eAAO,MAAM,oBAAoB,WAAW,CAAC;AAE7C,mFAAmF;AACnF,eAAO,MAAM,iCAAiC,kDACG,CAAC;AAElD,gGAAgG;AAChG,eAAO,MAAM,kCAAkC,2FAC2C,CAAC;AAE3F,iHAAiH;AACjH,eAAO,MAAM,sCAAsC,mEACe,CAAC;AAEnE,sEAAsE;AACtE,eAAO,MAAM,yCAAyC,6FACsC,CAAC;AAE7F,uGAAuG;AACvG,eAAO,MAAM,mCAAmC,2DACU,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sCAAsC,QAAiB,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The runner-subject lane's pinned names and copy — the one constants
3
+ * module for the runner-credential domain (the ts-server guideline:
4
+ * byte-pinned copy lives in one constants module per domain, never
5
+ * inline at the refusal site).
6
+ *
7
+ * Two refusal sentences for a PRESENTED credential, deliberately not
8
+ * more (the InvalidTokenError doctrine of runnerauth.ts: a finer reason
9
+ * invites branching on it). The runner is the only caller that ever
10
+ * presents a run credential, and the person reading these is its
11
+ * operator, in the runner's log:
12
+ *
13
+ * - the TOKEN sentence: the credential itself is not one this server
14
+ * will honor — forged, the wrong shape, bound to an execution or a
15
+ * connect this server does not have (a connect's row is gone once
16
+ * the connect settles), a clockless token bound to a connect (a shape
17
+ * no mint produces), a present `exp` in the past, or minted by a key
18
+ * this server does not hold. A missing row is this sentence and not
19
+ * NOT_FOUND on purpose: the credential is invalid, and the run is
20
+ * not the caller's to learn about.
21
+ * - the LIVENESS sentence: the credential is genuine but its run is
22
+ * over, or its run or connect was created by nobody this server
23
+ * recognizes as a person (the schedule fire caller's
24
+ * deterministic-refusal shape: no retry will make that run anyone's).
25
+ *
26
+ * And one for a REQUESTED credential — the platform exchange under the
27
+ * built-in posture (built-in-runner-credential-provider.ts), where the
28
+ * caller is a signed-in person asking for a run's credential and the
29
+ * answer is a permission, not a token verdict: only the person whose run
30
+ * it is may hold its credential. A run whose creator stamp names nobody
31
+ * gets the same sentence — no one is its person.
32
+ *
33
+ * The lineage mismatch copy is the cloud edition's, transcribed byte for
34
+ * byte (credentials/provider.ts in the composition; the Java
35
+ * RecordRunnerLineageLabelsStep before it) so the two editions refuse a
36
+ * mis-stamped lineage label with one sentence.
37
+ */
38
+ /** The verifier's name in the boot log and in auth failures (the `oidc` / `apikey` precedent). */
39
+ export const RUNNER_VERIFIER_NAME = "runner";
40
+ /** The token arms: forged, wrong shape, unknown execution, past `exp`, keyless. */
41
+ export const RUNNER_CREDENTIAL_INVALID_MESSAGE = "runner credential is not valid on this server";
42
+ /** The resolution arms: a terminal execution; a run stamped by nobody the server recognizes. */
43
+ export const RUNNER_CREDENTIAL_NOT_LIVE_MESSAGE = "runner credential names a run that is over or belongs to nobody this server recognizes";
44
+ /** The exchange's refusal under the built-in posture: the caller is not the run's person (PERMISSION_DENIED). */
45
+ export const RUN_CREDENTIAL_NOT_RUNS_PERSON_MESSAGE = "a run credential is minted only for the person whose run it is";
46
+ /** The cloud's byte-pinned lineage refusal (the Java step's copy). */
47
+ export const WORKFLOW_LINEAGE_BINDING_MISMATCH_MESSAGE = "workflow lineage label names a workflow execution this runner credential is not bound to";
48
+ /** The cloud's byte-pinned org-mismatch refusal (MemoryPolicy.MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE). */
49
+ export const MEMORY_CAPTURE_ORG_MISMATCH_MESSAGE = "memory capture is scoped to the session's organization";
50
+ /**
51
+ * How long a run credential outlives its run, measured from the row's
52
+ * `status.completed_at`. A run's credential is valid while the run is
53
+ * not terminal — runs wait on humans with no timeout, so no clock can
54
+ * bound them — and for this long after, because two legitimate runner
55
+ * writes land after the terminal stamp: the session-subject generation
56
+ * the workflow fires and does not await (issue #665), and a Temporal
57
+ * activity retried after its completion failed to reach the engine.
58
+ * Ten minutes covers one model call and one retry backoff; today's
59
+ * exchange-lane token outlives a run by up to an hour. A terminal row
60
+ * with no `completed_at` gets no grace: fail closed.
61
+ */
62
+ export const RUN_CREDENTIAL_GRACE_AFTER_TERMINAL_MS = 10 * 60 * 1000;
63
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/runnerauth/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,kGAAkG;AAClG,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAE7C,mFAAmF;AACnF,MAAM,CAAC,MAAM,iCAAiC,GAC5C,+CAA+C,CAAC;AAElD,gGAAgG;AAChG,MAAM,CAAC,MAAM,kCAAkC,GAC7C,wFAAwF,CAAC;AAE3F,iHAAiH;AACjH,MAAM,CAAC,MAAM,sCAAsC,GACjD,gEAAgE,CAAC;AAEnE,sEAAsE;AACtE,MAAM,CAAC,MAAM,yCAAyC,GACpD,0FAA0F,CAAC;AAE7F,uGAAuG;AACvG,MAAM,CAAC,MAAM,mCAAmC,GAC9C,wDAAwD,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The one reader of the provider's `mintRunCredential` capability for the
3
+ * two dispatch paths (temporal/agentexecution/engine-client.ts and
4
+ * temporal/workflowexecution/engine-client.ts). Both engines put the
5
+ * answer on the invoke workflow input as `execution_context_token` — the
6
+ * connect lane's key for the same token type (domain/mcpserver/engine.ts)
7
+ * — and omit the key when the answer is "".
8
+ *
9
+ * Three answers, one rule each:
10
+ *
11
+ * - the capability is absent: "" — this edition's runner is
12
+ * credentialed another way (the cloud bakes a sandbox credential at
13
+ * provision; runner-credential-provider.ts). Nothing to log: it is
14
+ * the composition's shape, not a condition.
15
+ * - the capability answers "": "" — the lane cannot mint (keyless, the
16
+ * modeled disabled state). The composition root makes a keyless
17
+ * server boot-fatal, so this is a test-only arm in practice.
18
+ * - the capability THROWS: one warning naming the execution, then "" —
19
+ * a dispatch never fails because a credential could not be minted
20
+ * (the connect lane's precedent, ruled 2026-09-16). The runner then
21
+ * falls back to the platform exchange and, refused there for a run
22
+ * that is not the key-holder's, reads redacted and fails the run
23
+ * loudly at its first read — attributable, never silent. The default
24
+ * provider throws only for an empty execution id (a programming
25
+ * error), so this arm exists to be pinned, not expected.
26
+ *
27
+ * The credential is never logged: the warning carries the execution id
28
+ * and the error's message, and the engines' own "Started …" lines carry
29
+ * ids and queues (a test pins the field names). A run credential in a log
30
+ * line would let anyone who reads the log act as the run's human for as
31
+ * long as the run lives.
32
+ */
33
+ import type { Logger } from "../boot/logger.js";
34
+ import type { RunnerCredentialProvider } from "./runner-credential-provider.js";
35
+ /** The dispatch's view of the seam: the one capability it reads. */
36
+ export type RunCredentialMint = Pick<RunnerCredentialProvider, "mintRunCredential">;
37
+ export declare function runCredentialForDispatch(credentials: RunCredentialMint, executionId: string, logger: Logger): string;
38
+ //# sourceMappingURL=dispatch-credential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-credential.d.ts","sourceRoot":"","sources":["../../src/runnerauth/dispatch-credential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAEhF,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,wBAAwB,EACxB,mBAAmB,CACpB,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,MAAM,CAiBR"}
@@ -0,0 +1,17 @@
1
+ export function runCredentialForDispatch(credentials, executionId, logger) {
2
+ const mintRunCredential = credentials.mintRunCredential?.bind(credentials);
3
+ if (mintRunCredential === undefined) {
4
+ return "";
5
+ }
6
+ try {
7
+ return mintRunCredential(executionId);
8
+ }
9
+ catch (error) {
10
+ logger.warn("Failed to mint the run credential — dispatching without it; the runner will fall back to the platform exchange", {
11
+ execution_id: executionId,
12
+ error: error instanceof Error ? error.message : String(error),
13
+ });
14
+ return "";
15
+ }
16
+ }
17
+ //# sourceMappingURL=dispatch-credential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-credential.js","sourceRoot":"","sources":["../../src/runnerauth/dispatch-credential.ts"],"names":[],"mappings":"AAyCA,MAAM,UAAU,wBAAwB,CACtC,WAA8B,EAC9B,WAAmB,EACnB,MAAc;IAEd,MAAM,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3E,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IAAI,CAAC;QACH,OAAO,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CACT,gHAAgH,EAChH;YACE,YAAY,EAAE,WAAW;YACzB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CACF,CAAC;QACF,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}