deepline 0.1.301 → 0.1.303
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/bundling-sources/sdk/src/client.ts +8 -0
- package/dist/bundling-sources/sdk/src/errors.ts +96 -36
- package/dist/bundling-sources/sdk/src/http.ts +82 -5
- package/dist/bundling-sources/sdk/src/index.ts +12 -0
- package/dist/bundling-sources/sdk/src/play.ts +29 -1
- package/dist/bundling-sources/sdk/src/release.ts +5 -3
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +120 -14
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +10 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +59 -11
- package/dist/bundling-sources/shared_libs/play-runtime/execution-ledger-store.ts +3 -3
- package/dist/bundling-sources/shared_libs/play-runtime/execution-plan.ts +0 -15
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +136 -36
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +17 -12
- package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +210 -5
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result-paths.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +4 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +33 -24
- package/dist/bundling-sources/shared_libs/play-runtime/work-receipts.ts +4 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-contract-version.ts +6 -0
- package/dist/bundling-sources/shared_libs/plays/artifact-types.ts +4 -0
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +159 -12
- package/dist/bundling-sources/shared_libs/plays/contracts.ts +69 -1
- package/dist/bundling-sources/shared_libs/tool-execution-error.ts +557 -0
- package/dist/cli/index.js +556 -183
- package/dist/cli/index.mjs +556 -183
- package/dist/index.d.mts +69 -40
- package/dist/index.d.ts +69 -40
- package/dist/index.js +480 -80
- package/dist/index.mjs +477 -80
- package/dist/plays/bundle-play-file.d.mts +4 -2
- package/dist/plays/bundle-play-file.d.ts +4 -2
- package/dist/plays/bundle-play-file.mjs +116 -19
- package/dist/tool-execution-error-YDz7UMl-.d.mts +440 -0
- package/dist/tool-execution-error-YDz7UMl-.d.ts +440 -0
- package/package.json +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/completed-receipt-cache.ts +0 -166
- package/dist/compiler-manifest-BjopNIqx.d.mts +0 -240
- package/dist/compiler-manifest-BjopNIqx.d.ts +0 -240
|
@@ -28,10 +28,13 @@ import type {
|
|
|
28
28
|
PlayRuntimeFeature,
|
|
29
29
|
} from '../artifact-types';
|
|
30
30
|
import { buildPlayContractCompatibility } from '../contracts';
|
|
31
|
+
import type { ToolExecutionErrorSchemaVersion } from '../../tool-execution-error';
|
|
31
32
|
import { validatePlaySourceFilesHaveNoInlineSecrets } from '../secret-guardrails';
|
|
32
33
|
import { MAX_PLAY_BUNDLE_BYTES } from './limits';
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
// The authored tool-error schema is part of the artifact bytes. Do not reuse a
|
|
36
|
+
// local bundle cached before compatibility selection entered graph analysis.
|
|
37
|
+
const PLAY_BUNDLE_CACHE_VERSION = 27;
|
|
35
38
|
const PLAY_ARTIFACT_CACHE_DIR = join(
|
|
36
39
|
tmpdir(),
|
|
37
40
|
`deepline-play-artifacts-v${PLAY_BUNDLE_CACHE_VERSION}`,
|
|
@@ -152,6 +155,7 @@ type SourceGraphAnalysis = {
|
|
|
152
155
|
importPolicy: PlayImportPolicy;
|
|
153
156
|
playName: string | null;
|
|
154
157
|
playDescription: string | null;
|
|
158
|
+
toolErrorSchemaVersion: ToolExecutionErrorSchemaVersion | null;
|
|
155
159
|
importedPlayDependencies: ImportedPlayDependency[];
|
|
156
160
|
};
|
|
157
161
|
|
|
@@ -501,6 +505,8 @@ type PlayMetadataExtractionContext = {
|
|
|
501
505
|
type ExtractedPlayMetadata = {
|
|
502
506
|
name: string | null;
|
|
503
507
|
description: string | null;
|
|
508
|
+
toolErrorSchemaVersion: ToolExecutionErrorSchemaVersion | null;
|
|
509
|
+
toolErrorSchemaVersionUnknown: boolean;
|
|
504
510
|
};
|
|
505
511
|
|
|
506
512
|
const TypeScriptParser = Parser.extend(
|
|
@@ -795,9 +801,13 @@ function staticStringFromExpression(
|
|
|
795
801
|
}
|
|
796
802
|
|
|
797
803
|
function propertyNameFromKey(property: AstNode): string | null {
|
|
798
|
-
if (property.computed) return null;
|
|
799
804
|
const key = isAstNode(property.key) ? property.key : null;
|
|
800
805
|
if (!key) return null;
|
|
806
|
+
if (property.computed) {
|
|
807
|
+
return key.type === 'Literal' && typeof key.value === 'string'
|
|
808
|
+
? key.value
|
|
809
|
+
: null;
|
|
810
|
+
}
|
|
801
811
|
if (key.type === 'Identifier' && typeof key.name === 'string') {
|
|
802
812
|
return key.name;
|
|
803
813
|
}
|
|
@@ -826,6 +836,109 @@ function objectExpressionFromNode(
|
|
|
826
836
|
);
|
|
827
837
|
}
|
|
828
838
|
|
|
839
|
+
type StaticPropertyResolution =
|
|
840
|
+
| { kind: 'absent' }
|
|
841
|
+
| { kind: 'found'; value: AstNode }
|
|
842
|
+
| { kind: 'unknown' };
|
|
843
|
+
|
|
844
|
+
function resolveStaticProperty(
|
|
845
|
+
node: AstNode | null | undefined,
|
|
846
|
+
propertyName: string,
|
|
847
|
+
context: PlayMetadataExtractionContext,
|
|
848
|
+
ancestors = new Set<AstNode>(),
|
|
849
|
+
): StaticPropertyResolution {
|
|
850
|
+
if (!node) return { kind: 'absent' };
|
|
851
|
+
const object = objectExpressionFromNode(node, context);
|
|
852
|
+
if (!object) return { kind: 'unknown' };
|
|
853
|
+
if (ancestors.has(object)) return { kind: 'unknown' };
|
|
854
|
+
const nextAncestors = new Set(ancestors).add(object);
|
|
855
|
+
|
|
856
|
+
let resolution: StaticPropertyResolution = { kind: 'absent' };
|
|
857
|
+
for (const property of astArray(object.properties)) {
|
|
858
|
+
if (property.type === 'SpreadElement') {
|
|
859
|
+
const spreadResolution = resolveStaticProperty(
|
|
860
|
+
isAstNode(property.argument) ? property.argument : null,
|
|
861
|
+
propertyName,
|
|
862
|
+
context,
|
|
863
|
+
nextAncestors,
|
|
864
|
+
);
|
|
865
|
+
if (spreadResolution.kind !== 'absent') {
|
|
866
|
+
resolution = spreadResolution;
|
|
867
|
+
}
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
if (property.type !== 'Property') continue;
|
|
871
|
+
const resolvedPropertyName = propertyNameFromKey(property);
|
|
872
|
+
if (resolvedPropertyName !== propertyName) {
|
|
873
|
+
if (property.computed && resolvedPropertyName === null) {
|
|
874
|
+
resolution = { kind: 'unknown' };
|
|
875
|
+
}
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
const propertyValue = property.shorthand ? property.key : property.value;
|
|
879
|
+
resolution = isAstNode(propertyValue)
|
|
880
|
+
? { kind: 'found', value: propertyValue }
|
|
881
|
+
: { kind: 'unknown' };
|
|
882
|
+
}
|
|
883
|
+
return resolution;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
function staticNumberFromExpression(
|
|
887
|
+
node: AstNode | null | undefined,
|
|
888
|
+
context: PlayMetadataExtractionContext,
|
|
889
|
+
seen = new Set<string>(),
|
|
890
|
+
): number | null {
|
|
891
|
+
const expression = unwrapStaticExpression(node);
|
|
892
|
+
if (!expression) return null;
|
|
893
|
+
if (expression.type === 'Literal' && typeof expression.value === 'number') {
|
|
894
|
+
return expression.value;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
const identifier = getIdentifierName(expression);
|
|
898
|
+
if (!identifier || seen.has(identifier)) return null;
|
|
899
|
+
seen.add(identifier);
|
|
900
|
+
return staticNumberFromExpression(
|
|
901
|
+
context.declarations.get(identifier),
|
|
902
|
+
context,
|
|
903
|
+
seen,
|
|
904
|
+
);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
function toolErrorSchemaVersionFromOptions(
|
|
908
|
+
node: AstNode | null | undefined,
|
|
909
|
+
context: PlayMetadataExtractionContext,
|
|
910
|
+
): ToolExecutionErrorSchemaVersion | null | undefined {
|
|
911
|
+
const directCompatibility = resolveStaticProperty(
|
|
912
|
+
node,
|
|
913
|
+
'compatibility',
|
|
914
|
+
context,
|
|
915
|
+
);
|
|
916
|
+
if (directCompatibility.kind === 'unknown') return null;
|
|
917
|
+
|
|
918
|
+
const bindings = resolveStaticProperty(node, 'bindings', context);
|
|
919
|
+
if (bindings.kind === 'unknown') return null;
|
|
920
|
+
const bindingCompatibility =
|
|
921
|
+
bindings.kind === 'found'
|
|
922
|
+
? resolveStaticProperty(bindings.value, 'compatibility', context)
|
|
923
|
+
: ({ kind: 'absent' } satisfies StaticPropertyResolution);
|
|
924
|
+
if (bindingCompatibility.kind === 'unknown') return null;
|
|
925
|
+
|
|
926
|
+
const compatibility =
|
|
927
|
+
directCompatibility.kind === 'found'
|
|
928
|
+
? directCompatibility
|
|
929
|
+
: bindingCompatibility;
|
|
930
|
+
if (compatibility.kind === 'absent') return undefined;
|
|
931
|
+
const schema = resolveStaticProperty(
|
|
932
|
+
compatibility.value,
|
|
933
|
+
'toolErrorSchemaVersion',
|
|
934
|
+
context,
|
|
935
|
+
);
|
|
936
|
+
if (schema.kind !== 'found') return null;
|
|
937
|
+
const schemaVersion = staticNumberFromExpression(schema.value, context);
|
|
938
|
+
if (schemaVersion === 0 || schemaVersion === 1) return schemaVersion;
|
|
939
|
+
return null;
|
|
940
|
+
}
|
|
941
|
+
|
|
829
942
|
function stringPropertyFromObjectExpression(
|
|
830
943
|
node: AstNode | null | undefined,
|
|
831
944
|
propertyName: string,
|
|
@@ -895,12 +1008,16 @@ function playMetadataFromDefinePlayCall(
|
|
|
895
1008
|
|
|
896
1009
|
const args = astArray(expression.arguments);
|
|
897
1010
|
const firstArg = args[0] ?? null;
|
|
1011
|
+
const isObjectForm =
|
|
1012
|
+
args.length === 1 || objectExpressionFromNode(firstArg, context) !== null;
|
|
898
1013
|
const objectName = stringPropertyFromObjectExpression(
|
|
899
1014
|
firstArg,
|
|
900
1015
|
'id',
|
|
901
1016
|
context,
|
|
902
1017
|
);
|
|
903
|
-
const name =
|
|
1018
|
+
const name = isObjectForm
|
|
1019
|
+
? objectName
|
|
1020
|
+
: staticStringFromExpression(firstArg, context);
|
|
904
1021
|
|
|
905
1022
|
let description =
|
|
906
1023
|
stringPropertyFromObjectExpression(firstArg, 'description', context) ??
|
|
@@ -913,8 +1030,27 @@ function playMetadataFromDefinePlayCall(
|
|
|
913
1030
|
);
|
|
914
1031
|
}
|
|
915
1032
|
|
|
916
|
-
|
|
917
|
-
|
|
1033
|
+
const options = isObjectForm ? firstArg : (args[2] ?? null);
|
|
1034
|
+
const toolErrorSchemaVersion = toolErrorSchemaVersionFromOptions(
|
|
1035
|
+
options,
|
|
1036
|
+
context,
|
|
1037
|
+
);
|
|
1038
|
+
const toolErrorSchemaVersionUnknown = toolErrorSchemaVersion === null;
|
|
1039
|
+
|
|
1040
|
+
if (
|
|
1041
|
+
!name &&
|
|
1042
|
+
!description &&
|
|
1043
|
+
toolErrorSchemaVersion === undefined &&
|
|
1044
|
+
!toolErrorSchemaVersionUnknown
|
|
1045
|
+
) {
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
return {
|
|
1049
|
+
name,
|
|
1050
|
+
description,
|
|
1051
|
+
toolErrorSchemaVersion: toolErrorSchemaVersion ?? null,
|
|
1052
|
+
toolErrorSchemaVersionUnknown,
|
|
1053
|
+
};
|
|
918
1054
|
}
|
|
919
1055
|
|
|
920
1056
|
function resolveExportExpression(
|
|
@@ -1397,14 +1533,18 @@ async function analyzeSourceGraph(
|
|
|
1397
1533
|
.sort((left, right) => left.filePath.localeCompare(right.filePath)),
|
|
1398
1534
|
}),
|
|
1399
1535
|
);
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1402
|
-
(exportName === 'default' ? extractDefinedPlayName(sourceCode) : null);
|
|
1403
|
-
const playDescription =
|
|
1404
|
-
extractDefinedPlayDescriptionForExport(sourceCode, exportName) ??
|
|
1536
|
+
const metadata =
|
|
1537
|
+
extractDefinedPlayMetadata(sourceCode, exportName) ??
|
|
1405
1538
|
(exportName === 'default'
|
|
1406
|
-
?
|
|
1539
|
+
? extractDefinedPlayMetadata(sourceCode, null)
|
|
1407
1540
|
: null);
|
|
1541
|
+
if (metadata?.toolErrorSchemaVersionUnknown) {
|
|
1542
|
+
throw new Error(
|
|
1543
|
+
'definePlay compatibility.toolErrorSchemaVersion must be the static literal 0 or 1.',
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
const playName = metadata?.name ?? null;
|
|
1547
|
+
const playDescription = metadata?.description ?? null;
|
|
1408
1548
|
|
|
1409
1549
|
return {
|
|
1410
1550
|
sourceCode,
|
|
@@ -1424,6 +1564,7 @@ async function analyzeSourceGraph(
|
|
|
1424
1564
|
},
|
|
1425
1565
|
playName,
|
|
1426
1566
|
playDescription,
|
|
1567
|
+
toolErrorSchemaVersion: metadata?.toolErrorSchemaVersion ?? null,
|
|
1427
1568
|
importedPlayDependencies: [...importedPlayDependencies.values()].sort(
|
|
1428
1569
|
(left, right) => left.filePath.localeCompare(right.filePath),
|
|
1429
1570
|
),
|
|
@@ -1672,6 +1813,10 @@ export async function bundlePlayFile(
|
|
|
1672
1813
|
entryFile: absolutePath,
|
|
1673
1814
|
sourceHash: analysis.sourceHash,
|
|
1674
1815
|
importPolicy: analysis.importPolicy,
|
|
1816
|
+
compatibility: buildPlayContractCompatibility({
|
|
1817
|
+
toolErrorSchemaVersion:
|
|
1818
|
+
analysis.toolErrorSchemaVersion ?? undefined,
|
|
1819
|
+
}),
|
|
1675
1820
|
cacheHit: true,
|
|
1676
1821
|
},
|
|
1677
1822
|
sourceCode: analysis.sourceCode,
|
|
@@ -1736,7 +1881,9 @@ export async function bundlePlayFile(
|
|
|
1736
1881
|
bundledCode: executableCode,
|
|
1737
1882
|
sourceMap: normalizedSourceMap,
|
|
1738
1883
|
importPolicy: analysis.importPolicy,
|
|
1739
|
-
compatibility: buildPlayContractCompatibility(
|
|
1884
|
+
compatibility: buildPlayContractCompatibility({
|
|
1885
|
+
toolErrorSchemaVersion: analysis.toolErrorSchemaVersion ?? undefined,
|
|
1886
|
+
}),
|
|
1740
1887
|
generatedAt: Date.now(),
|
|
1741
1888
|
cacheHit: false,
|
|
1742
1889
|
};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LEGACY_TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
|
|
3
|
+
SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS,
|
|
4
|
+
TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
|
|
5
|
+
type ToolExecutionErrorSchemaVersion,
|
|
6
|
+
} from '../tool-execution-error';
|
|
7
|
+
import { CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION } from './artifact-contract-version';
|
|
8
|
+
|
|
1
9
|
export type PlayContractSource = 'ad_hoc' | 'draft' | 'published';
|
|
2
10
|
|
|
3
11
|
export type PlayRuntimeFeature =
|
|
@@ -7,7 +15,7 @@ export type PlayRuntimeFeature =
|
|
|
7
15
|
| 'packaged_files';
|
|
8
16
|
|
|
9
17
|
export const PLAY_PUBLIC_API_VERSION = 1;
|
|
10
|
-
export const PLAY_ARTIFACT_VERSION =
|
|
18
|
+
export const PLAY_ARTIFACT_VERSION = CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION;
|
|
11
19
|
export const PLAY_MIN_RUNNER_VERSION = 1;
|
|
12
20
|
export const PLAY_RUNTIME_FEATURES: PlayRuntimeFeature[] = [
|
|
13
21
|
'artifact_storage',
|
|
@@ -22,10 +30,68 @@ export type PlayContractCompatibilitySnapshot = {
|
|
|
22
30
|
minRunnerVersion: number;
|
|
23
31
|
runtimeFeatures: PlayRuntimeFeature[];
|
|
24
32
|
runtimeBackend?: string | null;
|
|
33
|
+
/** Missing preserves the legacy contract used by artifacts stored before this field existed. */
|
|
34
|
+
toolErrorSchemaVersion?: ToolExecutionErrorSchemaVersion;
|
|
25
35
|
};
|
|
26
36
|
|
|
37
|
+
export type NormalizedPlayContractCompatibilitySnapshot =
|
|
38
|
+
PlayContractCompatibilitySnapshot & {
|
|
39
|
+
toolErrorSchemaVersion: ToolExecutionErrorSchemaVersion;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export class UnsupportedPlayToolErrorSchemaVersionError extends Error {
|
|
43
|
+
constructor(value: unknown) {
|
|
44
|
+
super(
|
|
45
|
+
`Unsupported Play tool error schema version ${String(value)}. Supported versions: ${SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS.join(', ')}.`,
|
|
46
|
+
);
|
|
47
|
+
this.name = 'UnsupportedPlayToolErrorSchemaVersionError';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class InvalidPlayContractCompatibilityError extends Error {
|
|
52
|
+
constructor() {
|
|
53
|
+
super('Play artifact compatibility must be an object.');
|
|
54
|
+
this.name = 'InvalidPlayContractCompatibilityError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Normalize the artifact-pinned compatibility facts without regenerating them.
|
|
60
|
+
* A missing field is the historical production contract, not an opt-in to the
|
|
61
|
+
* current runtime behavior.
|
|
62
|
+
*/
|
|
63
|
+
export function normalizePlayContractCompatibility(
|
|
64
|
+
compatibility: PlayContractCompatibilitySnapshot | null | undefined,
|
|
65
|
+
): NormalizedPlayContractCompatibilitySnapshot {
|
|
66
|
+
if (
|
|
67
|
+
!compatibility ||
|
|
68
|
+
typeof compatibility !== 'object' ||
|
|
69
|
+
Array.isArray(compatibility)
|
|
70
|
+
) {
|
|
71
|
+
throw new InvalidPlayContractCompatibilityError();
|
|
72
|
+
}
|
|
73
|
+
const toolErrorSchemaVersion =
|
|
74
|
+
compatibility.toolErrorSchemaVersion ??
|
|
75
|
+
LEGACY_TOOL_EXECUTION_ERROR_SCHEMA_VERSION;
|
|
76
|
+
if (
|
|
77
|
+
!SUPPORTED_TOOL_EXECUTION_ERROR_SCHEMA_VERSIONS.includes(
|
|
78
|
+
toolErrorSchemaVersion as ToolExecutionErrorSchemaVersion,
|
|
79
|
+
)
|
|
80
|
+
) {
|
|
81
|
+
throw new UnsupportedPlayToolErrorSchemaVersionError(
|
|
82
|
+
toolErrorSchemaVersion,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
...compatibility,
|
|
87
|
+
toolErrorSchemaVersion:
|
|
88
|
+
toolErrorSchemaVersion as ToolExecutionErrorSchemaVersion,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
27
92
|
export function buildPlayContractCompatibility(input?: {
|
|
28
93
|
runtimeBackend?: string | null;
|
|
94
|
+
toolErrorSchemaVersion?: ToolExecutionErrorSchemaVersion;
|
|
29
95
|
}): PlayContractCompatibilitySnapshot {
|
|
30
96
|
return {
|
|
31
97
|
apiVersion: PLAY_PUBLIC_API_VERSION,
|
|
@@ -33,6 +99,8 @@ export function buildPlayContractCompatibility(input?: {
|
|
|
33
99
|
minRunnerVersion: PLAY_MIN_RUNNER_VERSION,
|
|
34
100
|
runtimeFeatures: [...PLAY_RUNTIME_FEATURES],
|
|
35
101
|
runtimeBackend: input?.runtimeBackend ?? null,
|
|
102
|
+
toolErrorSchemaVersion:
|
|
103
|
+
input?.toolErrorSchemaVersion ?? TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
|
|
36
104
|
};
|
|
37
105
|
}
|
|
38
106
|
|