deepline 0.3.71 → 0.3.72
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/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +162 -62
- package/dist/bundling-sources/shared_libs/play-runtime/log-provenance.ts +116 -4
- package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +4 -1
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +10 -5
- package/dist/cli/index.js +324 -123
- package/dist/cli/index.mjs +324 -123
- package/dist/{compiler-manifest-IkyvsUO-.d.mts → compiler-manifest-CMNgA_JQ.d.mts} +7 -1
- package/dist/{compiler-manifest-IkyvsUO-.d.ts → compiler-manifest-CMNgA_JQ.d.ts} +7 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +32 -3
- package/dist/index.mjs +32 -3
- package/dist/install-integrity.json +2 -2
- package/dist/plays/bundle-play-file.d.mts +2 -2
- package/dist/plays/bundle-play-file.d.ts +2 -2
- package/dist/plays/bundle-play-file.mjs +1 -1
- package/package.json +1 -1
|
@@ -52,6 +52,27 @@ export type LogProvenance =
|
|
|
52
52
|
* Never customer-facing. */
|
|
53
53
|
| 'receipt';
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* How urgent a log line is. This is deliberately independent from provenance:
|
|
57
|
+
* a customer can write an error, while a runtime can emit a harmless debug
|
|
58
|
+
* detail. CLI log-level filters use this ordered taxonomy.
|
|
59
|
+
*/
|
|
60
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
61
|
+
|
|
62
|
+
export const LOG_LEVELS: readonly LogLevel[] = [
|
|
63
|
+
'debug',
|
|
64
|
+
'info',
|
|
65
|
+
'warn',
|
|
66
|
+
'error',
|
|
67
|
+
] as const;
|
|
68
|
+
|
|
69
|
+
const LOG_LEVEL_RANK: Record<LogLevel, number> = {
|
|
70
|
+
debug: 0,
|
|
71
|
+
info: 1,
|
|
72
|
+
warn: 2,
|
|
73
|
+
error: 3,
|
|
74
|
+
};
|
|
75
|
+
|
|
55
76
|
/** Every provenance class, for exhaustiveness checks and tests. */
|
|
56
77
|
export const LOG_PROVENANCE_CLASSES: readonly LogProvenance[] = [
|
|
57
78
|
'user',
|
|
@@ -125,6 +146,51 @@ export function tagLogProvenance(
|
|
|
125
146
|
return `${PROVENANCE_PREFIX}${provenance}${PROVENANCE_SENTINEL}${line}`;
|
|
126
147
|
}
|
|
127
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Persist a severity in text that released readers can still render sensibly.
|
|
151
|
+
* The provenance tag is already a compatible structural carrier; level text
|
|
152
|
+
* must remain readable after an older client strips only that provenance tag.
|
|
153
|
+
*/
|
|
154
|
+
export function tagLogLevel(line: string, level: LogLevel): string {
|
|
155
|
+
const timestamp = line.match(/^(\[[^\]]+\]\s*)/u)?.[1] ?? '';
|
|
156
|
+
const message = timestamp ? line.slice(timestamp.length) : line;
|
|
157
|
+
const explicitLevel = message.match(/^\[(debug|info|warn|error)\]\s*/i);
|
|
158
|
+
// The caller-selected severity is authoritative, but customer text remains
|
|
159
|
+
// immutable. Add a framework marker before a conflicting customer prefix
|
|
160
|
+
// instead of replacing the author's original `[warn]`/`[error]` wording.
|
|
161
|
+
if (explicitLevel?.[1]?.toLowerCase() === level) return line;
|
|
162
|
+
const needsInfoDisambiguation =
|
|
163
|
+
level === 'info' &&
|
|
164
|
+
(explicitLevel !== null ||
|
|
165
|
+
/^\[console\.(?:debug|warn|error)\]/i.test(message));
|
|
166
|
+
if (level === 'info' && !needsInfoDisambiguation) {
|
|
167
|
+
return line;
|
|
168
|
+
}
|
|
169
|
+
return `${timestamp}[${level}] ${message}`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Tag a new log line with both independent dimensions. */
|
|
173
|
+
export function tagLogEntry(
|
|
174
|
+
provenance: LogProvenance,
|
|
175
|
+
level: LogLevel,
|
|
176
|
+
line: string,
|
|
177
|
+
): string {
|
|
178
|
+
return tagLogProvenance(provenance, tagLogLevel(line, level));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** True when a line at `level` reaches a minimum-severity filter. */
|
|
182
|
+
export function logLevelReaches(level: LogLevel, minimum: LogLevel): boolean {
|
|
183
|
+
return LOG_LEVEL_RANK[level] >= LOG_LEVEL_RANK[minimum];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Parse a user-supplied log level without accepting a silently ignored value. */
|
|
187
|
+
export function parseLogLevel(value: string): LogLevel | null {
|
|
188
|
+
const normalized = value.trim().toLowerCase();
|
|
189
|
+
return LOG_LEVELS.includes(normalized as LogLevel)
|
|
190
|
+
? (normalized as LogLevel)
|
|
191
|
+
: null;
|
|
192
|
+
}
|
|
193
|
+
|
|
128
194
|
/**
|
|
129
195
|
* A customer-safe record of a `ctx.fetch` response that reached the server but
|
|
130
196
|
* was not successful. Its URL is destination-origin-only; it deliberately
|
|
@@ -179,9 +245,10 @@ export function parseCtxFetchHttpFailureDiagnostic(
|
|
|
179
245
|
): CtxFetchHttpFailureDiagnostic | null {
|
|
180
246
|
const tagged = readProvenanceTag(rawLine);
|
|
181
247
|
if (tagged.provenance !== 'diagnostic') return null;
|
|
182
|
-
const
|
|
248
|
+
const line = tagged.line;
|
|
249
|
+
const index = line.indexOf(CTX_FETCH_HTTP_FAILURE_LOG_PREFIX);
|
|
183
250
|
if (index === -1) return null;
|
|
184
|
-
const json =
|
|
251
|
+
const json = line
|
|
185
252
|
.slice(index + CTX_FETCH_HTTP_FAILURE_LOG_PREFIX.length)
|
|
186
253
|
.trim();
|
|
187
254
|
try {
|
|
@@ -296,13 +363,58 @@ export function classifyLegacyLogLine(line: string): LogProvenance {
|
|
|
296
363
|
*/
|
|
297
364
|
export function classifyLogLine(line: string): {
|
|
298
365
|
provenance: LogProvenance;
|
|
366
|
+
level: LogLevel;
|
|
299
367
|
line: string;
|
|
300
368
|
} {
|
|
301
369
|
const tagged = readProvenanceTag(line);
|
|
370
|
+
const provenance = tagged.provenance ?? classifyLegacyLogLine(tagged.line);
|
|
302
371
|
if (tagged.provenance !== null) {
|
|
303
|
-
return {
|
|
372
|
+
return {
|
|
373
|
+
provenance,
|
|
374
|
+
level: inferLogLevel(provenance, tagged.line),
|
|
375
|
+
line: tagged.line,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
provenance,
|
|
380
|
+
level: inferLogLevel(provenance, tagged.line),
|
|
381
|
+
line: tagged.line,
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Compatibility classification for lines that predate explicit level tags.
|
|
387
|
+
* New runtime-authored lines should use `tagLogEntry`; these rules keep old
|
|
388
|
+
* run history useful without pretending arbitrary customer text is an error.
|
|
389
|
+
*/
|
|
390
|
+
function inferLogLevel(provenance: LogProvenance, line: string): LogLevel {
|
|
391
|
+
const message = stripLeadingTimestamp(line);
|
|
392
|
+
if (/^\[info\]/i.test(message)) {
|
|
393
|
+
return 'info';
|
|
394
|
+
}
|
|
395
|
+
if (/^\[debug\]/i.test(message)) {
|
|
396
|
+
return 'debug';
|
|
397
|
+
}
|
|
398
|
+
if (/^\[console\.error\]/i.test(message) || /^\[error\]/i.test(message)) {
|
|
399
|
+
return 'error';
|
|
400
|
+
}
|
|
401
|
+
if (/^\[console\.warn\]/i.test(message) || /^\[warn\]/i.test(message)) {
|
|
402
|
+
return 'warn';
|
|
403
|
+
}
|
|
404
|
+
if (/^\[console\.debug\]/i.test(message)) {
|
|
405
|
+
return 'debug';
|
|
406
|
+
}
|
|
407
|
+
if (
|
|
408
|
+
provenance === 'replay' ||
|
|
409
|
+
provenance === 'infra' ||
|
|
410
|
+
provenance === 'receipt'
|
|
411
|
+
) {
|
|
412
|
+
return 'debug';
|
|
413
|
+
}
|
|
414
|
+
if (provenance === 'diagnostic') {
|
|
415
|
+
return 'warn';
|
|
304
416
|
}
|
|
305
|
-
return
|
|
417
|
+
return 'info';
|
|
306
418
|
}
|
|
307
419
|
|
|
308
420
|
/** True when a raw (possibly tagged) log line should render on the surface. */
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
type PlayActivityObservation,
|
|
22
22
|
type PlayRunActivityProjection,
|
|
23
23
|
} from './activity-observation';
|
|
24
|
+
import { stripProvenanceTag } from './log-provenance';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Run Snapshot Stream.
|
|
@@ -238,7 +239,9 @@ function buildSnapshotFromLedger(
|
|
|
238
239
|
durationMs: snapshot.durationMs ?? null,
|
|
239
240
|
updatedAt:
|
|
240
241
|
snapshot.updatedAt ?? snapshot.finishedAt ?? snapshot.startedAt ?? null,
|
|
241
|
-
|
|
242
|
+
// This snapshot is public SDK/API transport. Keep the historical plain
|
|
243
|
+
// timestamp-prefixed text while provenance remains runtime metadata.
|
|
244
|
+
logs: snapshot.logTail.map(stripProvenanceTag),
|
|
242
245
|
totalLogCount: snapshot.totalLogCount,
|
|
243
246
|
...(snapshot.logsTruncated ? { logsTruncated: true } : {}),
|
|
244
247
|
activeArtifactTableNamespace: snapshot.activeArtifactTableNamespace ?? null,
|
|
@@ -456,9 +456,7 @@ export type PlayAuthoringCronInput<TInput> = TInput extends readonly unknown[]
|
|
|
456
456
|
: never;
|
|
457
457
|
|
|
458
458
|
/** The one public type for options accepted by definePlay. */
|
|
459
|
-
export type PlayAuthoringBindings<
|
|
460
|
-
TInput = Record<string, unknown>,
|
|
461
|
-
> = {
|
|
459
|
+
export type PlayAuthoringBindings<TInput = Record<string, unknown>> = {
|
|
462
460
|
description?: string;
|
|
463
461
|
compatibility?: {
|
|
464
462
|
toolErrorSchemaVersion?: ToolExecutionErrorSchemaVersion;
|
|
@@ -1239,7 +1237,14 @@ export interface PlayAuthoringRuntimeContext {
|
|
|
1239
1237
|
options: PlayAuthoringCallOptions,
|
|
1240
1238
|
): Promise<TOutput>;
|
|
1241
1239
|
|
|
1242
|
-
|
|
1240
|
+
/**
|
|
1241
|
+
* Write a customer-safe line to the durable Run Log Stream. Omitting level
|
|
1242
|
+
* preserves the historical info-level behavior.
|
|
1243
|
+
*/
|
|
1244
|
+
log(
|
|
1245
|
+
message: string,
|
|
1246
|
+
options?: { level?: 'debug' | 'info' | 'warn' | 'error' },
|
|
1247
|
+
): void;
|
|
1243
1248
|
sleep(ms: number): Promise<void>;
|
|
1244
1249
|
}
|
|
1245
1250
|
|
|
@@ -2783,7 +2788,7 @@ export const PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
|
|
|
2783
2788
|
" fetch(key: string, url: string | URL, init?: RequestInit & { headers?: HeadersInit & { 'Idempotency-Key'?: string; 'X-Idempotency-Key'?: string }; auth?: SecretAuthInput }, options?: FetchOptions): Promise<PlayFetchResponse>;",
|
|
2784
2789
|
' secrets: { get(name: string): SecretPromise; bearer(secret: string | SecretPromise | SecretHandle): SecretAuth; header(header: string, secret: string | SecretPromise | SecretHandle): SecretAuth };',
|
|
2785
2790
|
` runPlay<TOutput = unknown>(key: string, playRef: ${cloudReferenceType('ctx.runPlay.playRef')}, input: ${cloudReferenceType('ctx.runPlay.input')}, options: PlayCallOptions): Promise<TOutput>;`,
|
|
2786
|
-
|
|
2791
|
+
" log(message: string, options?: { level?: 'debug' | 'info' | 'warn' | 'error' }): void;",
|
|
2787
2792
|
` sleep(ms: ${cloudReferenceType('ctx.sleep.ms')}): Promise<void>;`,
|
|
2788
2793
|
'}',
|
|
2789
2794
|
"export type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = { id: string; description?: string; input: PlayInputContract<TInput>; run: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>; bindings?: PlayBindings<TInput>; billing?: PlayBindings<TInput>['billing']; runtime?: PlayBindings<TInput>['runtime']; compatibility?: PlayBindings<TInput>['compatibility'] };",
|