deepline 0.1.8 → 0.1.9
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/cli/index.js +6 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +6 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +78 -19
- package/dist/repo/apps/play-runner-workers/src/entry.ts +35 -22
- package/dist/repo/sdk/src/http.ts +8 -0
- package/dist/repo/sdk/src/version.ts +1 -1
- package/dist/repo/shared_libs/play-runtime/coordinator-headers.ts +3 -1
- package/dist/repo/shared_libs/play-runtime/scheduler-backend.ts +6 -1
- package/package.json +1 -1
|
@@ -89,6 +89,7 @@ import {
|
|
|
89
89
|
type ToolExecuteResult,
|
|
90
90
|
type ToolResultMetadataInput,
|
|
91
91
|
} from './runtime/tool-result';
|
|
92
|
+
import { coordinatorRequestHeaders } from '../../../shared_libs/play-runtime/coordinator-headers';
|
|
92
93
|
|
|
93
94
|
// The play's default export. The bundler injects this — see bundle-play-file.ts.
|
|
94
95
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -130,6 +131,8 @@ type RunRequest = {
|
|
|
130
131
|
playCallGovernance?: PlayCallGovernanceSnapshot | null;
|
|
131
132
|
/** Cloudflare coordinator URL for direct Workflow control-plane signals. */
|
|
132
133
|
coordinatorUrl?: string | null;
|
|
134
|
+
/** Request-scoped coordinator auth token for preview/dev direct control calls. */
|
|
135
|
+
coordinatorInternalToken?: string | null;
|
|
133
136
|
/**
|
|
134
137
|
* Total input rows known at submit time, when the dispatcher can count them.
|
|
135
138
|
* `undefined` when the input streams from R2 (unknown row count).
|
|
@@ -761,6 +764,12 @@ async function submitChildPlayThroughCoordinator(input: {
|
|
|
761
764
|
logs?: string[];
|
|
762
765
|
timings?: Array<{ phase: string; ms: number }>;
|
|
763
766
|
}> {
|
|
767
|
+
if (cachedCoordinatorBinding) {
|
|
768
|
+
if (!isRecord(input.body)) {
|
|
769
|
+
throw new Error('ctx.runPlay child submit requires an object body.');
|
|
770
|
+
}
|
|
771
|
+
return cachedCoordinatorBinding.submitChild(input.req.runId, input.body);
|
|
772
|
+
}
|
|
764
773
|
const coordinatorUrl = input.req.coordinatorUrl?.trim();
|
|
765
774
|
if (coordinatorUrl) {
|
|
766
775
|
// Keep child plays on the same coordinator/Workflow submit path as
|
|
@@ -772,8 +781,12 @@ async function submitChildPlayThroughCoordinator(input: {
|
|
|
772
781
|
{
|
|
773
782
|
method: 'POST',
|
|
774
783
|
headers: {
|
|
775
|
-
'content-type': 'application/json',
|
|
776
784
|
'x-deepline-request-id': makeRequestId(),
|
|
785
|
+
...coordinatorRequestHeaders({
|
|
786
|
+
runId: input.req.runId,
|
|
787
|
+
contentType: 'application/json',
|
|
788
|
+
internalToken: input.req.coordinatorInternalToken,
|
|
789
|
+
}),
|
|
777
790
|
},
|
|
778
791
|
body: JSON.stringify(input.body),
|
|
779
792
|
},
|
|
@@ -796,14 +809,8 @@ async function submitChildPlayThroughCoordinator(input: {
|
|
|
796
809
|
}
|
|
797
810
|
return parsed;
|
|
798
811
|
}
|
|
799
|
-
if (cachedCoordinatorBinding) {
|
|
800
|
-
if (!isRecord(input.body)) {
|
|
801
|
-
throw new Error('ctx.runPlay child submit requires an object body.');
|
|
802
|
-
}
|
|
803
|
-
return cachedCoordinatorBinding.submitChild(input.req.runId, input.body);
|
|
804
|
-
}
|
|
805
812
|
throw new Error(
|
|
806
|
-
'ctx.runPlay child submit requires
|
|
813
|
+
'ctx.runPlay child submit requires a coordinator binding in the cf-workflows runtime.',
|
|
807
814
|
);
|
|
808
815
|
}
|
|
809
816
|
|
|
@@ -948,7 +955,6 @@ async function signalParentPlayTerminal(input: {
|
|
|
948
955
|
: {}),
|
|
949
956
|
emittedAt: nowMs(),
|
|
950
957
|
};
|
|
951
|
-
const coordinatorUrl = input.req.coordinatorUrl?.trim();
|
|
952
958
|
const signalBody = {
|
|
953
959
|
signal: 'integration_event',
|
|
954
960
|
eventKey,
|
|
@@ -958,6 +964,7 @@ async function signalParentPlayTerminal(input: {
|
|
|
958
964
|
await cachedCoordinatorBinding.signal(governance.parentRunId, signalBody);
|
|
959
965
|
return;
|
|
960
966
|
}
|
|
967
|
+
const coordinatorUrl = input.req.coordinatorUrl?.trim();
|
|
961
968
|
if (coordinatorUrl) {
|
|
962
969
|
const res = await fetch(
|
|
963
970
|
`${coordinatorUrl.replace(/\/$/, '')}/workflow/${encodeURIComponent(
|
|
@@ -966,26 +973,27 @@ async function signalParentPlayTerminal(input: {
|
|
|
966
973
|
{
|
|
967
974
|
method: 'POST',
|
|
968
975
|
headers: {
|
|
969
|
-
'content-type': 'application/json',
|
|
970
976
|
'x-deepline-request-id': makeRequestId(),
|
|
977
|
+
...coordinatorRequestHeaders({
|
|
978
|
+
runId: governance.parentRunId,
|
|
979
|
+
contentType: 'application/json',
|
|
980
|
+
internalToken: input.req.coordinatorInternalToken,
|
|
981
|
+
}),
|
|
971
982
|
},
|
|
972
983
|
body: JSON.stringify(signalBody),
|
|
973
984
|
},
|
|
974
985
|
);
|
|
975
|
-
if (
|
|
976
|
-
|
|
977
|
-
throw new Error(
|
|
978
|
-
`Coordinator signal ${res.status}: ${text.slice(0, 800)}`,
|
|
979
|
-
);
|
|
986
|
+
if (res.ok) {
|
|
987
|
+
return;
|
|
980
988
|
}
|
|
981
|
-
|
|
989
|
+
const text = await res.text().catch(() => '');
|
|
990
|
+
throw new Error(
|
|
991
|
+
text.slice(0, 800) || `Coordinator parent signal failed with ${res.status}.`,
|
|
992
|
+
);
|
|
982
993
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
eventKey,
|
|
987
|
-
data,
|
|
988
|
-
});
|
|
994
|
+
throw new Error(
|
|
995
|
+
'Child play terminal signaling requires a coordinator binding in the cf-workflows runtime.',
|
|
996
|
+
);
|
|
989
997
|
}
|
|
990
998
|
|
|
991
999
|
async function executeTool(
|
|
@@ -4483,6 +4491,11 @@ function runRequestFromWorkflowParams(
|
|
|
4483
4491
|
typeof params.coordinatorUrl === 'string' && params.coordinatorUrl.trim()
|
|
4484
4492
|
? params.coordinatorUrl.trim()
|
|
4485
4493
|
: null,
|
|
4494
|
+
coordinatorInternalToken:
|
|
4495
|
+
typeof params.coordinatorInternalToken === 'string' &&
|
|
4496
|
+
params.coordinatorInternalToken.trim()
|
|
4497
|
+
? params.coordinatorInternalToken.trim()
|
|
4498
|
+
: null,
|
|
4486
4499
|
totalRows:
|
|
4487
4500
|
typeof params.totalRows === 'number' && Number.isFinite(params.totalRows)
|
|
4488
4501
|
? params.totalRows
|
|
@@ -23,6 +23,7 @@ import { AuthError, DeeplineError, RateLimitError } from './errors.js';
|
|
|
23
23
|
import { SDK_API_CONTRACT, SDK_VERSION } from './version.js';
|
|
24
24
|
import type { LiveEventEnvelope } from './types.js';
|
|
25
25
|
import {
|
|
26
|
+
COORDINATOR_INTERNAL_TOKEN_HEADER,
|
|
26
27
|
COORDINATOR_URL_OVERRIDE_HEADER,
|
|
27
28
|
WORKER_CALLBACK_URL_OVERRIDE_HEADER,
|
|
28
29
|
} from '../../shared_libs/play-runtime/coordinator-headers.js';
|
|
@@ -84,6 +85,13 @@ export class HttpClient {
|
|
|
84
85
|
: undefined;
|
|
85
86
|
if (coordinatorUrl?.trim()) {
|
|
86
87
|
headers[COORDINATOR_URL_OVERRIDE_HEADER] = coordinatorUrl.trim();
|
|
88
|
+
const coordinatorInternalToken = typeof process !== 'undefined'
|
|
89
|
+
? process.env?.DEEPLINE_INTERNAL_TOKEN
|
|
90
|
+
: undefined;
|
|
91
|
+
if (coordinatorInternalToken?.trim()) {
|
|
92
|
+
headers[COORDINATOR_INTERNAL_TOKEN_HEADER] =
|
|
93
|
+
coordinatorInternalToken.trim();
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
96
|
const workerCallbackUrl = typeof process !== 'undefined'
|
|
89
97
|
? process.env?.DEEPLINE_WORKER_CALLBACK_URL
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.1.
|
|
1
|
+
export const SDK_VERSION = "0.1.9";
|
|
2
2
|
export const SDK_API_CONTRACT = "2026-04-plays-v1";
|
|
@@ -51,6 +51,7 @@ function resolveInternalCoordinatorToken(): string | null {
|
|
|
51
51
|
export function coordinatorRequestHeaders(input: {
|
|
52
52
|
runId: string;
|
|
53
53
|
contentType?: string | null;
|
|
54
|
+
internalToken?: string | null;
|
|
54
55
|
/**
|
|
55
56
|
* When set, the coordinator validates this matches the runId in the URL.
|
|
56
57
|
* Pass the runId on `/cancel` / `/signal` calls so a leaked dispatcher
|
|
@@ -66,7 +67,8 @@ export function coordinatorRequestHeaders(input: {
|
|
|
66
67
|
if (trimmed) {
|
|
67
68
|
headers[COORDINATOR_VERSION_KEY_HEADER] = trimmed;
|
|
68
69
|
}
|
|
69
|
-
const internalToken =
|
|
70
|
+
const internalToken =
|
|
71
|
+
input.internalToken?.trim() || resolveInternalCoordinatorToken();
|
|
70
72
|
if (internalToken) {
|
|
71
73
|
headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = internalToken;
|
|
72
74
|
}
|
|
@@ -94,6 +94,8 @@ export type PlaySchedulerSubmitInput = {
|
|
|
94
94
|
totalRows?: number;
|
|
95
95
|
/** Internal scheduler/coordinator URL for Worker-side capabilities. */
|
|
96
96
|
coordinatorUrl?: string | null;
|
|
97
|
+
/** Request-scoped coordinator auth token for non-production preview/dev runs. */
|
|
98
|
+
coordinatorInternalToken?: string | null;
|
|
97
99
|
};
|
|
98
100
|
|
|
99
101
|
export type PlaySchedulerProgressEvent =
|
|
@@ -151,7 +153,10 @@ export interface PlaySchedulerBackend {
|
|
|
151
153
|
/** Open a handle to an already-submitted run (e.g. for tail-reconnect). */
|
|
152
154
|
attach(
|
|
153
155
|
runId: string,
|
|
154
|
-
options?: {
|
|
156
|
+
options?: {
|
|
157
|
+
coordinatorUrl?: string | null;
|
|
158
|
+
coordinatorInternalToken?: string | null;
|
|
159
|
+
},
|
|
155
160
|
): Promise<PlaySchedulerRunHandle>;
|
|
156
161
|
}
|
|
157
162
|
|