deepline 0.3.547 → 0.3.549
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-core.ts +93 -11
- package/dist/bundling-sources/sdk/src/index.ts +1 -0
- package/dist/bundling-sources/sdk/src/plays/check-local-play-graph.ts +3 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +11 -0
- package/dist/bundling-sources/shared_libs/monitors/action-actor.ts +203 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +20 -0
- package/dist/bundling-sources/shared_libs/monitors/package.json +2 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +33 -0
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +19 -3
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-failure-codes.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +83 -6
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +93 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +98 -1
- package/dist/bundling-sources/shared_libs/plays/play-check-compact.ts +636 -0
- package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +3 -0
- package/dist/bundling-sources/shared_libs/security/email-domain.ts +24 -0
- package/dist/cli/auth-UVEZIP3H.js +43 -0
- package/dist/cli/{auth-WJEY4IDX.mjs → auth-YENF525S.mjs} +5 -5
- package/dist/cli/{billing-IJITDDRQ.js → billing-52GAHIDZ.js} +95 -95
- package/dist/cli/{billing-PHJUDYF3.mjs → billing-XPXB27G7.mjs} +9 -9
- package/dist/cli/{chunk-2HPTLBNB.js → chunk-3IUQNHIG.js} +3 -3
- package/dist/cli/{chunk-IKYN6PLO.mjs → chunk-4AUV5QJF.mjs} +5 -5
- package/dist/cli/{chunk-GZFZZQL4.js → chunk-4DJNXAPH.js} +75 -37
- package/dist/cli/{chunk-DZC7LMYM.js → chunk-4HSSPT73.js} +6 -6
- package/dist/cli/{chunk-TNJG4ZPN.mjs → chunk-4QUWXUUJ.mjs} +35 -6
- package/dist/cli/{chunk-SAJWYN4B.js → chunk-5622PYAP.js} +4 -4
- package/dist/cli/{chunk-PBMO36BP.mjs → chunk-5CXE22BI.mjs} +2 -2
- package/dist/cli/{chunk-ESCVHDNY.mjs → chunk-5T37KQNG.mjs} +5 -5
- package/dist/cli/{chunk-YURGAKI3.js → chunk-7FY7AHR6.js} +2 -2
- package/dist/cli/{chunk-PVQCX6KQ.js → chunk-ADWMIZCB.js} +67 -9
- package/dist/cli/{chunk-FMQXAOVE.mjs → chunk-ANOTB6V3.mjs} +4 -4
- package/dist/cli/{chunk-VPF54TXQ.mjs → chunk-AZSVDAXT.mjs} +5 -5
- package/dist/cli/{chunk-G6XTCG3J.mjs → chunk-BDOLPGHD.mjs} +2 -2
- package/dist/cli/{chunk-N63U5CRG.js → chunk-BDUZJX4V.js} +26 -26
- package/dist/cli/{chunk-HFIFKP3A.js → chunk-BPBPY42E.js} +5 -5
- package/dist/cli/{chunk-ECUD4QPD.mjs → chunk-CX4KGWCH.mjs} +3 -3
- package/dist/cli/{chunk-REAFIEV5.js → chunk-CXFOYRI4.js} +99 -99
- package/dist/cli/{chunk-RXRC2COC.mjs → chunk-DCTEH6N5.mjs} +2 -2
- package/dist/cli/{chunk-ABLTVG3J.js → chunk-DIRLEJJX.js} +41 -41
- package/dist/cli/{chunk-VNOQEDVC.js → chunk-ETLEPHLT.js} +7 -7
- package/dist/cli/{chunk-QU3K3IY6.js → chunk-HPSCRVTM.js} +12 -12
- package/dist/cli/{chunk-MBQELFL7.js → chunk-HWCIU3KY.js} +22 -22
- package/dist/cli/{chunk-XMBVHJPR.mjs → chunk-J6FINSAK.mjs} +49 -11
- package/dist/cli/{chunk-K3GMDSUX.js → chunk-KBMBNUUW.js} +5 -5
- package/dist/cli/{chunk-D6OIEH47.js → chunk-KTZ3VU6S.js} +5 -5
- package/dist/cli/{chunk-XNTDTAKC.mjs → chunk-L6UMWAAY.mjs} +1 -1
- package/dist/cli/{chunk-ITLZBDSR.mjs → chunk-LMFTDDAM.mjs} +2 -2
- package/dist/cli/{chunk-56MEAGWA.mjs → chunk-LP2VNGG3.mjs} +2 -2
- package/dist/cli/{chunk-RMCCB3XY.mjs → chunk-MAE3AKDR.mjs} +67 -9
- package/dist/cli/{chunk-L5J6UJ2X.js → chunk-NVALIJQS.js} +15 -15
- package/dist/cli/{chunk-MO7TGNXB.js → chunk-OWX4AAJ4.js} +13 -13
- package/dist/cli/{chunk-DIUNDLSX.mjs → chunk-PLAJ6HPD.mjs} +2 -2
- package/dist/cli/{chunk-G6KW764N.mjs → chunk-PLJCY35C.mjs} +1 -1
- package/dist/cli/{chunk-L6QE2XVM.mjs → chunk-PQX4WTBY.mjs} +1 -1
- package/dist/cli/{chunk-GJOGFWX3.js → chunk-QGKX2WBZ.js} +52 -23
- package/dist/cli/{chunk-AEQ5VWZ5.mjs → chunk-QIZBUY2N.mjs} +4 -4
- package/dist/cli/{chunk-E2OIYPB4.js → chunk-QUELC3B2.js} +10 -10
- package/dist/cli/{chunk-OVYXYTEP.js → chunk-RMKRZJOS.js} +16 -16
- package/dist/cli/{chunk-GIGAYLY6.js → chunk-SVNAP2QI.js} +9 -9
- package/dist/cli/{chunk-2AHY47SI.js → chunk-TYOAOSDL.js} +3 -3
- package/dist/cli/{chunk-GPAWLXW3.mjs → chunk-U6KHWIAO.mjs} +1 -1
- package/dist/cli/{chunk-MOZEAGSR.mjs → chunk-UGVXHT62.mjs} +1 -1
- package/dist/cli/{chunk-QLE3QKJ2.mjs → chunk-V5WPYOAE.mjs} +5 -5
- package/dist/cli/{chunk-FFBXLFKV.js → chunk-V7WMNX4R.js} +1 -1
- package/dist/cli/{chunk-NBYFQZ6O.js → chunk-VLAJGF27.js} +2 -2
- package/dist/cli/{chunk-5SFHPMBY.mjs → chunk-W77LBYF3.mjs} +11 -11
- package/dist/cli/{chunk-DJI5CLLW.mjs → chunk-X4RGDE4J.mjs} +1 -1
- package/dist/cli/{chunk-IVFFCAV2.js → chunk-XPYCNA43.js} +44 -44
- package/dist/cli/{chunk-HARZ4AAX.mjs → chunk-XS72HELO.mjs} +1 -1
- package/dist/cli/{chunk-LMLSOHTU.js → chunk-Y5MDCPWA.js} +53 -53
- package/dist/cli/{chunk-CKIRKYW7.mjs → chunk-Y5SKYU5X.mjs} +3 -3
- package/dist/cli/{chunk-Z2YGQZWV.mjs → chunk-YX7BX2FA.mjs} +2 -2
- package/dist/cli/{chunk-YVKLF7RW.js → chunk-YZTS3XA7.js} +2 -2
- package/dist/cli/{chunk-IGAK22XO.mjs → chunk-Z3DKJOUL.mjs} +1 -1
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/concurrent-runs-help-74AFW3BD.js +21 -0
- package/dist/cli/{concurrent-runs-help-ZNGP563R.mjs → concurrent-runs-help-OYSLW55L.mjs} +6 -6
- package/dist/cli/{csv-X6D4ZELE.js → csv-FRO3UFMQ.js} +13 -13
- package/dist/cli/{csv-VAHQHYYV.mjs → csv-TFCTUYF2.mjs} +4 -4
- package/dist/cli/{db-4G4S2VOV.mjs → db-NHVZBT2H.mjs} +6 -6
- package/dist/cli/{db-YA5ZGVEX.js → db-SNFNRVZJ.js} +27 -27
- package/dist/cli/describe-2JCOC4AK.js +50 -0
- package/dist/cli/{describe-EVXEM2S6.mjs → describe-OVFPRJJL.mjs} +18 -18
- package/dist/cli/describe-core.d.mts +2 -2
- package/dist/cli/describe-core.d.ts +2 -2
- package/dist/cli/{executions-HR6CTN5M.mjs → executions-HWMH2LTC.mjs} +6 -6
- package/dist/cli/{executions-5YC7ABF6.js → executions-RZLKKPZV.js} +8 -8
- package/dist/cli/{feedback-MJHSYLFF.js → feedback-3D5OROCI.js} +14 -14
- package/dist/cli/{feedback-GEU5SPLR.mjs → feedback-WD4JVF77.mjs} +6 -6
- package/dist/cli/git-GCCPCUWJ.js +25 -0
- package/dist/cli/{git-NPFF6QUS.mjs → git-RYUKBCUZ.mjs} +5 -5
- package/dist/cli/index.js +146 -146
- package/dist/cli/index.mjs +45 -45
- package/dist/cli/{integrations-Z7EGVBHF.mjs → integrations-KJPFCEXL.mjs} +7 -7
- package/dist/cli/{integrations-YPHFI77G.js → integrations-Y7OK23DW.js} +15 -15
- package/dist/cli/{legacy-noops-5IYCFWWX.mjs → legacy-noops-2PU2ZVEP.mjs} +6 -6
- package/dist/cli/{legacy-noops-246E3KKG.js → legacy-noops-G7ZY7K3K.js} +9 -9
- package/dist/cli/{mcp-WUYGZXPI.mjs → mcp-D7F2RSOI.mjs} +4 -4
- package/dist/cli/{mcp-YTYTW67G.js → mcp-GILBYX72.js} +24 -24
- package/dist/cli/{monitors-73DQKCU7.mjs → monitors-IK5KXY2H.mjs} +32 -8
- package/dist/cli/{monitors-SA6ILD6Z.js → monitors-OXNHOT3C.js} +125 -101
- package/dist/cli/{org-WVQRB2KX.mjs → org-L5D7EISU.mjs} +6 -6
- package/dist/cli/{org-X7ELDV7B.js → org-OYM3UNTP.js} +88 -88
- package/dist/cli/{play-QI6V2EUQ.mjs → play-PK6QO3WX.mjs} +837 -290
- package/dist/cli/{play-QTYOAJPE.js → play-YK22QPYO.js} +1423 -876
- package/dist/cli/{providers-XXFLVREV.js → providers-5CYP7P4N.js} +9 -9
- package/dist/cli/{providers-DPVMVDS4.mjs → providers-Z6MNJDCG.mjs} +6 -6
- package/dist/cli/{quickstart-YWGNHULM.mjs → quickstart-2I73XQXB.mjs} +4 -4
- package/dist/cli/{quickstart-33ISXQJU.js → quickstart-2YKETYJY.js} +6 -6
- package/dist/cli/{run-J6FCAKQC.mjs → run-KGQ6TUBB.mjs} +23 -23
- package/dist/cli/{run-BWHZXLTD.js → run-YVSEAVE5.js} +43 -43
- package/dist/cli/{search-Z3UU3WBB.mjs → search-V2HPN6FU.mjs} +7 -7
- package/dist/cli/search-YG3UIZ6A.js +32 -0
- package/dist/cli/{search-output-YIPV74ME.js → search-output-BUSANFRN.js} +6 -6
- package/dist/cli/{search-output-OJYY4J7E.mjs → search-output-OCTOSDEO.mjs} +4 -4
- package/dist/cli/{secrets-UXRJCEN4.js → secrets-VDKTHCVB.js} +15 -15
- package/dist/cli/{secrets-YZZN2WST.mjs → secrets-WZGRBWI5.mjs} +6 -6
- package/dist/cli/{sessions-ITCGPD7Z.mjs → sessions-5DTN55DZ.mjs} +6 -6
- package/dist/cli/sessions-NSPT6LHT.js +22 -0
- package/dist/cli/{settings-LAFYMILP.js → settings-A7VSNOLI.js} +85 -85
- package/dist/cli/{settings-ZP2LSVNM.mjs → settings-BK5FPQ3X.mjs} +12 -12
- package/dist/cli/{setup-WEQAQSYC.mjs → setup-LLQVPZTP.mjs} +9 -9
- package/dist/cli/{setup-4AL3XYM5.js → setup-NV27CYQ5.js} +49 -49
- package/dist/cli/{skills-NQH4HFW2.mjs → skills-IV6HK4XA.mjs} +7 -7
- package/dist/cli/skills-UA5E4DA3.js +36 -0
- package/dist/cli/{tools-CXK2GSI4.mjs → tools-4FKPCRD7.mjs} +17 -17
- package/dist/cli/tools-NJVPAG37.js +57 -0
- package/dist/cli/update-DKX27XZB.js +34 -0
- package/dist/cli/{update-3ROF3Z75.mjs → update-MH5M746E.mjs} +9 -9
- package/dist/cli/{views-XJFO5CEH.js → views-JW44TCGL.js} +21 -21
- package/dist/cli/{views-AOUHVGV2.mjs → views-KXC4JDT7.mjs} +6 -6
- package/dist/cli/{workflow-GY3DBHXX.js → workflow-F5AHL2ET.js} +17 -17
- package/dist/cli/{workflow-KBS2QJK6.mjs → workflow-FI4DL7ZI.mjs} +7 -7
- package/dist/{client-D1uWA2Vc.d.mts → client-BEJqhQAj.d.mts} +1 -1
- package/dist/{client-Hz7SsBXs.d.ts → client-Ceo295L2.d.ts} +1 -1
- package/dist/{client-core-D3Ad7Flt.d.ts → client-core-BPYuWfBC.d.ts} +49 -1
- package/dist/{client-core-Db_e63Hb.d.mts → client-core-BqetRxx-.d.mts} +49 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +118 -116
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-AC5277PI.js +0 -43
- package/dist/cli/concurrent-runs-help-ZYISYOQA.js +0 -21
- package/dist/cli/describe-GYYSLZLV.js +0 -50
- package/dist/cli/git-FZIQZNI4.js +0 -25
- package/dist/cli/search-JCWJX2XD.js +0 -32
- package/dist/cli/sessions-NA4SJH6Q.js +0 -22
- package/dist/cli/skills-XZ4Y6SZ7.js +0 -36
- package/dist/cli/tools-WJQ6Y7E4.js +0 -57
- package/dist/cli/update-ZLRLTBRD.js +0 -34
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The compact view of a `plays check` result: one shape for the API's
|
|
3
|
+
* `full: false` response, the CLI's `deepline plays check --json` and the MCP
|
|
4
|
+
* `deepline_check_play` tool.
|
|
5
|
+
*
|
|
6
|
+
* Output projection only. The compiled static pipeline, the authoring contract
|
|
7
|
+
* and everything `plays publish` stores are untouched; the complete document
|
|
8
|
+
* stays available with `full` (API, MCP) or `--full` (CLI).
|
|
9
|
+
*
|
|
10
|
+
* Two steps, both pure:
|
|
11
|
+
* - {@link compactPlayCheckResult} is the wire shape. It keeps `errors` and
|
|
12
|
+
* `warnings` as strings, because the CLI appends its own local diagnostics
|
|
13
|
+
* (bundle and authoring errors, repair hints) before presenting, and the
|
|
14
|
+
* input JSON Schema, which the CLI's run example reads.
|
|
15
|
+
* - {@link presentPlayCheckResult} is what a reader gets. `errors` and
|
|
16
|
+
* `warnings` fold into `issues` (one entry per diagnostic, never a mirror),
|
|
17
|
+
* the input is one field list, the diagram's boxes carry their lines, and
|
|
18
|
+
* anything at its default (runtime limit, budgets well within their limit)
|
|
19
|
+
* is left out.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS } from './sandbox-runtime-limits';
|
|
23
|
+
|
|
24
|
+
type RecordValue = Record<string, unknown>;
|
|
25
|
+
|
|
26
|
+
const record = (value: unknown): RecordValue | undefined =>
|
|
27
|
+
value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
28
|
+
? (value as RecordValue)
|
|
29
|
+
: undefined;
|
|
30
|
+
const array = (value: unknown): unknown[] =>
|
|
31
|
+
Array.isArray(value) ? value : [];
|
|
32
|
+
const text = (value: unknown): string | undefined =>
|
|
33
|
+
typeof value === 'string' && value.trim() ? value : undefined;
|
|
34
|
+
const strings = (value: unknown): string[] =>
|
|
35
|
+
array(value).filter((item): item is string => typeof item === 'string');
|
|
36
|
+
const nonEmpty = <T>(items: T[]): T[] | undefined =>
|
|
37
|
+
items.length ? items : undefined;
|
|
38
|
+
|
|
39
|
+
/** Marks a check result that is already compact, so no reader projects twice. */
|
|
40
|
+
export const PLAY_CHECK_COMPACT_VIEW = 'compact';
|
|
41
|
+
|
|
42
|
+
/** A structured check issue, as the API returns it. */
|
|
43
|
+
export type PlayCheckIssueShape = {
|
|
44
|
+
code: string;
|
|
45
|
+
severity: 'error' | 'warning';
|
|
46
|
+
message: string;
|
|
47
|
+
path?: string;
|
|
48
|
+
hint?: string;
|
|
49
|
+
node?: string;
|
|
50
|
+
line?: number;
|
|
51
|
+
fix?: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* One stage of the play per line: `type id (tool) · L<start>-<end> · description`.
|
|
56
|
+
* A stage inside another is indented two spaces under it. A conditional's arm
|
|
57
|
+
* is its own `→ <condition>` line with the steps it runs indented beneath it,
|
|
58
|
+
* so each step appears once, under the arm that runs it.
|
|
59
|
+
*/
|
|
60
|
+
export type PlayCheckCompactStage = string;
|
|
61
|
+
|
|
62
|
+
/** Marks a conditional arm's line in {@link PlayCheckCompactStage}s. */
|
|
63
|
+
export const PLAY_CHECK_ARM_PREFIX = '→ ';
|
|
64
|
+
|
|
65
|
+
/** One drawn box, with its code binding merged in when it has one. */
|
|
66
|
+
export type PlayCheckCompactNode = {
|
|
67
|
+
id: string;
|
|
68
|
+
label: string;
|
|
69
|
+
kind?: string;
|
|
70
|
+
/** Drawn, never run (`class … sketch`). */
|
|
71
|
+
sketch?: true;
|
|
72
|
+
/** Its `// @mermaid-node` annotation's line; absent when the box is unbound. */
|
|
73
|
+
line?: number;
|
|
74
|
+
/** The file holding that line, when the binding names one. */
|
|
75
|
+
file?: string;
|
|
76
|
+
in?: string[];
|
|
77
|
+
out?: string[];
|
|
78
|
+
show?: string[];
|
|
79
|
+
arm?: string;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type PlayCheckCompactDocflow = {
|
|
83
|
+
nodes: PlayCheckCompactNode[];
|
|
84
|
+
edges: Array<{ from: string; to: string; label?: string; arm?: string }>;
|
|
85
|
+
subgraphs?: Array<{
|
|
86
|
+
id: string;
|
|
87
|
+
label: string;
|
|
88
|
+
memberIds: string[];
|
|
89
|
+
parentId?: string;
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** One field of the play's input; a nested object's fields are dotted. */
|
|
94
|
+
export type PlayCheckInputField = {
|
|
95
|
+
name: string;
|
|
96
|
+
type: string;
|
|
97
|
+
required: boolean;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type CompactPlayCheckResult = {
|
|
101
|
+
view: typeof PLAY_CHECK_COMPACT_VIEW;
|
|
102
|
+
valid: boolean;
|
|
103
|
+
errors: string[];
|
|
104
|
+
warnings: string[];
|
|
105
|
+
issues: PlayCheckIssueShape[];
|
|
106
|
+
summary?: string;
|
|
107
|
+
recognized?: RecordValue;
|
|
108
|
+
triggers?: unknown;
|
|
109
|
+
inputSchema?: unknown;
|
|
110
|
+
returnFields?: unknown[];
|
|
111
|
+
stages?: PlayCheckCompactStage[];
|
|
112
|
+
docflow?: PlayCheckCompactDocflow;
|
|
113
|
+
runtimeLimit?: unknown;
|
|
114
|
+
/** Only the budgets at or past {@link PLAY_CHECK_NEAR_LIMIT_RATIO} of their limit. */
|
|
115
|
+
limits?: RecordValue;
|
|
116
|
+
/** Only when run would refuse this source. */
|
|
117
|
+
runAdmission?: RecordValue;
|
|
118
|
+
toolGetterHints?: unknown[];
|
|
119
|
+
sourceHash?: string;
|
|
120
|
+
artifactHash?: string;
|
|
121
|
+
graphHash?: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** A budget is reported once it uses this share of its limit. */
|
|
125
|
+
export const PLAY_CHECK_NEAR_LIMIT_RATIO = 0.8;
|
|
126
|
+
|
|
127
|
+
export function isCompactPlayCheckResult(
|
|
128
|
+
value: unknown,
|
|
129
|
+
): value is CompactPlayCheckResult {
|
|
130
|
+
return record(value)?.view === PLAY_CHECK_COMPACT_VIEW;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** The complete check document's static pipeline, wherever it was put. */
|
|
134
|
+
export function playCheckStaticPipeline(
|
|
135
|
+
result: RecordValue,
|
|
136
|
+
): RecordValue | undefined {
|
|
137
|
+
return record(
|
|
138
|
+
result.staticPipeline ?? record(result.authoringContract)?.staticPipeline,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const withoutUndefined = <T extends RecordValue>(value: T): T =>
|
|
143
|
+
Object.fromEntries(
|
|
144
|
+
Object.entries(value).filter(([, item]) => item !== undefined),
|
|
145
|
+
) as T;
|
|
146
|
+
|
|
147
|
+
function stageLocation(step: RecordValue): string | undefined {
|
|
148
|
+
const range = record(step.sourceRange);
|
|
149
|
+
const start = range?.startLine;
|
|
150
|
+
if (typeof start !== 'number') return undefined;
|
|
151
|
+
const end = typeof range?.endLine === 'number' ? range.endLine : start;
|
|
152
|
+
const lines = end === start ? `L${start}` : `L${start}-${end}`;
|
|
153
|
+
// A stage found inside a helper the play calls may live in another file.
|
|
154
|
+
const file = text(range?.sourcePath);
|
|
155
|
+
const callerFile = text(record(step.callSiteRange)?.sourcePath);
|
|
156
|
+
return file && callerFile && file !== callerFile ? `${file}:${lines}` : lines;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Descriptions and ids the analyzer made up from the line range or the stage
|
|
161
|
+
* type say nothing the line's type and range do not.
|
|
162
|
+
*/
|
|
163
|
+
const isGeneratedDescription = (description: string) =>
|
|
164
|
+
/^Lines \d+-\d+$/.test(description) ||
|
|
165
|
+
description === 'Conditional code' ||
|
|
166
|
+
description === 'Looped code';
|
|
167
|
+
const isGeneratedId = (id: string) =>
|
|
168
|
+
/^(?:lines|conditional|loop)_\d+_\d+$/.test(id);
|
|
169
|
+
|
|
170
|
+
/** Source text on one line: a multi-line condition reads the same. */
|
|
171
|
+
const oneLine = (value: string | undefined) =>
|
|
172
|
+
value?.replace(/\s+/g, ' ').trim() || undefined;
|
|
173
|
+
|
|
174
|
+
/** `type id`, plus `(target)` when the tool or play it calls is named otherwise. */
|
|
175
|
+
function stageHead(type: string, id: string | undefined, target?: string) {
|
|
176
|
+
const named = id && !isGeneratedId(id) ? `${type} ${id}` : type;
|
|
177
|
+
return target && target !== id ? `${named} (${target})` : named;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function stageLine(step: RecordValue, hasBranches: boolean): string {
|
|
181
|
+
const type = text(step.type) ?? 'step';
|
|
182
|
+
const kind = text(step.kind);
|
|
183
|
+
const id =
|
|
184
|
+
text(step.field) ?? text(step.alias) ?? text(step.id) ?? text(step.name);
|
|
185
|
+
const description = text(step.description);
|
|
186
|
+
return [
|
|
187
|
+
stageHead(
|
|
188
|
+
type === 'control_flow' && kind ? kind : type,
|
|
189
|
+
id,
|
|
190
|
+
text(step.toolId) ?? text(step.tool) ?? text(step.playId),
|
|
191
|
+
),
|
|
192
|
+
stageLocation(step),
|
|
193
|
+
// A conditional's arms each carry their own condition.
|
|
194
|
+
type === 'control_flow' && !hasBranches
|
|
195
|
+
? oneLine(text(step.condition))
|
|
196
|
+
: undefined,
|
|
197
|
+
step.inLoop === true ? 'in loop' : undefined,
|
|
198
|
+
description && !isGeneratedDescription(description)
|
|
199
|
+
? description
|
|
200
|
+
: undefined,
|
|
201
|
+
]
|
|
202
|
+
.filter(Boolean)
|
|
203
|
+
.join(' · ');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function waterfallLeg(leg: RecordValue): string {
|
|
207
|
+
return stageHead(text(leg.kind) ?? 'tool', text(leg.id), text(leg.toolId));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function branchLine(branch: RecordValue): string {
|
|
211
|
+
const label = oneLine(text(branch.label));
|
|
212
|
+
const condition = oneLine(text(branch.condition));
|
|
213
|
+
// A `case 'x'` label already is its condition.
|
|
214
|
+
if (!condition || label?.endsWith(condition)) return label ?? 'branch';
|
|
215
|
+
return label ? `${label} ${condition}` : condition;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const records = (value: unknown) =>
|
|
219
|
+
array(value)
|
|
220
|
+
.map(record)
|
|
221
|
+
.filter((item): item is RecordValue => Boolean(item));
|
|
222
|
+
|
|
223
|
+
/** One stage and everything under it, as lines indented from its own. */
|
|
224
|
+
function stageLines(step: RecordValue): string[] {
|
|
225
|
+
const indent = (lines: string[]) => lines.map((line) => ` ${line}`);
|
|
226
|
+
const branches = records(step.branches);
|
|
227
|
+
if (step.type === 'control_flow' && branches.length > 0) {
|
|
228
|
+
// `steps` repeats every arm's steps flattened; each arm already has them.
|
|
229
|
+
// An arm that runs no stage says nothing a reader can act on.
|
|
230
|
+
return [
|
|
231
|
+
stageLine(step, true),
|
|
232
|
+
...branches.flatMap((branch) => {
|
|
233
|
+
const steps = stagesLines(branch.steps);
|
|
234
|
+
return steps.length
|
|
235
|
+
? indent([`${PLAY_CHECK_ARM_PREFIX}${branchLine(branch)}`, ...indent(steps)])
|
|
236
|
+
: [];
|
|
237
|
+
}),
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
const children = records(step.steps);
|
|
241
|
+
return [
|
|
242
|
+
stageLine(step, false),
|
|
243
|
+
...indent(
|
|
244
|
+
step.type === 'waterfall'
|
|
245
|
+
? children.map(waterfallLeg)
|
|
246
|
+
: stagesLines(children),
|
|
247
|
+
),
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* The analyzer lists a helper's stage once per time it reaches it, as
|
|
253
|
+
* identical copies; one line with its count says the same.
|
|
254
|
+
*/
|
|
255
|
+
function stagesLines(steps: unknown): string[] {
|
|
256
|
+
const out: string[] = [];
|
|
257
|
+
let previous: string | undefined;
|
|
258
|
+
let run = 0;
|
|
259
|
+
let start = 0;
|
|
260
|
+
for (const step of records(steps)) {
|
|
261
|
+
const lines = stageLines(step);
|
|
262
|
+
const key = lines.join('\n');
|
|
263
|
+
if (key === previous) {
|
|
264
|
+
run += 1;
|
|
265
|
+
out[start] = `${lines[0]} ×${run}`;
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
previous = key;
|
|
269
|
+
run = 1;
|
|
270
|
+
start = out.length;
|
|
271
|
+
out.push(...lines);
|
|
272
|
+
}
|
|
273
|
+
return out;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* The play's stages, then the row steps (`substeps`) not already shown under
|
|
278
|
+
* the stage that runs them.
|
|
279
|
+
*/
|
|
280
|
+
function compactStages(pipeline: RecordValue): string[] {
|
|
281
|
+
const lines = stagesLines(pipeline.stages);
|
|
282
|
+
const shown = new Set(lines.map((line) => line.trim()));
|
|
283
|
+
return [
|
|
284
|
+
...lines,
|
|
285
|
+
...stagesLines(
|
|
286
|
+
records(pipeline.substeps).filter(
|
|
287
|
+
(step) => !shown.has(stageLine(step, false)),
|
|
288
|
+
),
|
|
289
|
+
),
|
|
290
|
+
];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function compactDocflow(
|
|
294
|
+
docflow: RecordValue | undefined,
|
|
295
|
+
): PlayCheckCompactDocflow | undefined {
|
|
296
|
+
if (!docflow || !Array.isArray(docflow.nodes)) return undefined;
|
|
297
|
+
const bindings = new Map<string, RecordValue>();
|
|
298
|
+
for (const binding of records(docflow.bindings)) {
|
|
299
|
+
const nodeId = text(binding.nodeId);
|
|
300
|
+
// Two bindings on one box is itself a reported issue; keep the first.
|
|
301
|
+
if (nodeId && !bindings.has(nodeId)) bindings.set(nodeId, binding);
|
|
302
|
+
}
|
|
303
|
+
const nodes = records(docflow.nodes).map((node) => {
|
|
304
|
+
const id = String(node.id);
|
|
305
|
+
const binding = bindings.get(id);
|
|
306
|
+
return withoutUndefined({
|
|
307
|
+
id,
|
|
308
|
+
label: text(node.label) ?? id,
|
|
309
|
+
// A plain box is an action; only other kinds are named.
|
|
310
|
+
kind: text(node.kind) === 'action' ? undefined : text(node.kind),
|
|
311
|
+
sketch: node.sketch === true ? (true as const) : undefined,
|
|
312
|
+
line: binding
|
|
313
|
+
? typeof binding.line === 'number'
|
|
314
|
+
? binding.line
|
|
315
|
+
: 0
|
|
316
|
+
: undefined,
|
|
317
|
+
file: text(binding?.sourcePath),
|
|
318
|
+
in: nonEmpty(strings(binding?.inputs)),
|
|
319
|
+
out: nonEmpty(strings(binding?.outputs)),
|
|
320
|
+
show: nonEmpty(strings(binding?.show)),
|
|
321
|
+
arm: text(binding?.arm),
|
|
322
|
+
}) as PlayCheckCompactNode;
|
|
323
|
+
});
|
|
324
|
+
const edges = records(docflow.edges).map((edge) =>
|
|
325
|
+
withoutUndefined({
|
|
326
|
+
from: String(edge.from),
|
|
327
|
+
to: String(edge.to),
|
|
328
|
+
label: text(edge.label),
|
|
329
|
+
arm: text(edge.arm),
|
|
330
|
+
}),
|
|
331
|
+
);
|
|
332
|
+
const subgraphs = records(docflow.subgraphs).map((region) =>
|
|
333
|
+
withoutUndefined({
|
|
334
|
+
id: String(region.id),
|
|
335
|
+
label: text(region.label) ?? String(region.id),
|
|
336
|
+
memberIds: strings(region.memberIds),
|
|
337
|
+
parentId: text(region.parentId),
|
|
338
|
+
}),
|
|
339
|
+
);
|
|
340
|
+
return withoutUndefined({ nodes, edges, subgraphs: nonEmpty(subgraphs) });
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function nearLimits(limits: RecordValue | undefined): RecordValue | undefined {
|
|
344
|
+
if (!limits) return undefined;
|
|
345
|
+
const near = Object.entries(limits).filter(([, value]) => {
|
|
346
|
+
const budget = record(value);
|
|
347
|
+
if (!budget) return false;
|
|
348
|
+
if (budget.withinLimit === false || budget.approachingLimit === true)
|
|
349
|
+
return true;
|
|
350
|
+
const used = budget.usedBytes ?? budget.used;
|
|
351
|
+
const limit = budget.limitBytes ?? budget.limit;
|
|
352
|
+
return (
|
|
353
|
+
typeof used === 'number' &&
|
|
354
|
+
typeof limit === 'number' &&
|
|
355
|
+
limit > 0 &&
|
|
356
|
+
used >= limit * PLAY_CHECK_NEAR_LIMIT_RATIO
|
|
357
|
+
);
|
|
358
|
+
});
|
|
359
|
+
return near.length ? Object.fromEntries(near) : undefined;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/** The same issue reported twice (same code, place and words) is shown once. */
|
|
363
|
+
function distinctIssues(issues: PlayCheckIssueShape[]): PlayCheckIssueShape[] {
|
|
364
|
+
const seen = new Set<string>();
|
|
365
|
+
return issues.filter((issue) => {
|
|
366
|
+
const key = JSON.stringify(issue);
|
|
367
|
+
if (seen.has(key)) return false;
|
|
368
|
+
seen.add(key);
|
|
369
|
+
return true;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* The compact wire view of a complete check document. A result that is
|
|
375
|
+
* already compact is returned as is.
|
|
376
|
+
*/
|
|
377
|
+
export function compactPlayCheckResult(
|
|
378
|
+
result: RecordValue,
|
|
379
|
+
): CompactPlayCheckResult {
|
|
380
|
+
if (isCompactPlayCheckResult(result)) return result;
|
|
381
|
+
const contract = record(result.authoringContract);
|
|
382
|
+
const pipeline = playCheckStaticPipeline(result);
|
|
383
|
+
const admission = record(result.runAdmission);
|
|
384
|
+
return withoutUndefined({
|
|
385
|
+
view: PLAY_CHECK_COMPACT_VIEW,
|
|
386
|
+
valid: result.valid === true,
|
|
387
|
+
errors: strings(result.errors),
|
|
388
|
+
warnings: strings(result.warnings),
|
|
389
|
+
issues: distinctIssues(array(result.issues) as PlayCheckIssueShape[]),
|
|
390
|
+
summary: text(result.summary),
|
|
391
|
+
recognized: record(result.recognized),
|
|
392
|
+
triggers: result.triggers ?? undefined,
|
|
393
|
+
inputSchema: contract?.inputSchema ?? undefined,
|
|
394
|
+
returnFields: nonEmpty(array(pipeline?.returnFields)),
|
|
395
|
+
stages: pipeline ? nonEmpty(compactStages(pipeline)) : undefined,
|
|
396
|
+
docflow: compactDocflow(record(pipeline?.docflow)),
|
|
397
|
+
runtimeLimit: result.runtimeLimit ?? undefined,
|
|
398
|
+
limits: nearLimits(record(result.limits)),
|
|
399
|
+
runAdmission:
|
|
400
|
+
admission && admission.admitted === false ? admission : undefined,
|
|
401
|
+
toolGetterHints: nonEmpty(array(result.toolGetterHints)),
|
|
402
|
+
sourceHash: text(result.sourceHash),
|
|
403
|
+
artifactHash: text(result.artifactHash),
|
|
404
|
+
graphHash: text(result.graphHash),
|
|
405
|
+
}) as CompactPlayCheckResult;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Tool ids the CLI looks up getter hints for: every tool stage of the play,
|
|
410
|
+
* including one inside a loop, a dataset or a conditional arm. A child play's
|
|
411
|
+
* tools belong to that play's own check.
|
|
412
|
+
*/
|
|
413
|
+
export function playCheckToolIds(result: RecordValue): string[] {
|
|
414
|
+
const ids = new Set<string>();
|
|
415
|
+
for (const stage of compactPlayCheckResult(result).stages ?? []) {
|
|
416
|
+
// `tool <id>` or `tool <id> (<toolId>)`; see stageHead.
|
|
417
|
+
const match = /^tool (\S+)(?: \((\S+)\))?(?: ·|$| ×)/.exec(stage.trim());
|
|
418
|
+
const tool = match?.[2] ?? match?.[1];
|
|
419
|
+
if (tool) ids.add(tool);
|
|
420
|
+
}
|
|
421
|
+
return [...ids].sort();
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function schemaType(schema: RecordValue): string {
|
|
425
|
+
const values = array(schema.enum);
|
|
426
|
+
if (values.length > 0 && values.length <= 6) {
|
|
427
|
+
return values.map((value) => JSON.stringify(value)).join('|');
|
|
428
|
+
}
|
|
429
|
+
const members = [...records(schema.anyOf), ...records(schema.oneOf)];
|
|
430
|
+
if (members.length > 0) return members.map(schemaType).join('|');
|
|
431
|
+
const types = [...strings(schema.type), text(schema.type)].filter(
|
|
432
|
+
(type): type is string => Boolean(type),
|
|
433
|
+
);
|
|
434
|
+
if (types.length === 0) return 'unknown';
|
|
435
|
+
return types
|
|
436
|
+
.map((type) => {
|
|
437
|
+
const items = record(schema.items);
|
|
438
|
+
return type === 'array' && items ? `${schemaType(items)}[]` : type;
|
|
439
|
+
})
|
|
440
|
+
.join('|');
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* The play's input as one list of fields, in declared order: a nested
|
|
445
|
+
* object's fields are dotted (`company.domain`), and one is required only
|
|
446
|
+
* when it and every object holding it are. The CSV field a batch play reads
|
|
447
|
+
* is typed `csv`.
|
|
448
|
+
*/
|
|
449
|
+
export function playCheckInputFields(
|
|
450
|
+
schema: unknown,
|
|
451
|
+
): PlayCheckInputField[] | undefined {
|
|
452
|
+
const root = record(schema);
|
|
453
|
+
if (!root) return undefined;
|
|
454
|
+
const csvField = text(record(root.csvInput)?.inputField);
|
|
455
|
+
const fields: PlayCheckInputField[] = [];
|
|
456
|
+
const visit = (node: RecordValue, prefix: string, required: boolean) => {
|
|
457
|
+
const requiredKeys = new Set(strings(node.required));
|
|
458
|
+
for (const [key, value] of Object.entries(record(node.properties) ?? {})) {
|
|
459
|
+
const name = prefix ? `${prefix}.${key}` : key;
|
|
460
|
+
const property = record(value) ?? {};
|
|
461
|
+
const isRequired = required && requiredKeys.has(key);
|
|
462
|
+
if (Object.keys(record(property.properties) ?? {}).length > 0) {
|
|
463
|
+
visit(property, name, isRequired);
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
fields.push({
|
|
467
|
+
name,
|
|
468
|
+
type: !prefix && key === csvField ? 'csv' : schemaType(property),
|
|
469
|
+
required: isRequired,
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
visit(root, '', true);
|
|
474
|
+
return fields;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const isDiagramIssue = (issue: PlayCheckIssueShape) =>
|
|
478
|
+
issue.code.startsWith('docflow_');
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* The standing recommendation to draw a diagram at all. A diagram is optional,
|
|
482
|
+
* so a play without one gets no diagram counts; the issue itself stays for
|
|
483
|
+
* clients that offer an authoring prompt.
|
|
484
|
+
*/
|
|
485
|
+
export const isOptionalDiagramNudge = (issue: PlayCheckIssueShape) =>
|
|
486
|
+
issue.code === 'docflow_visualization_missing' &&
|
|
487
|
+
issue.message.startsWith('HIGHLY RECOMMENDED');
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Names the box a diagram issue is about when the server did not: its path is
|
|
491
|
+
* `docflow.nodes.<id>…` or `docflow.subgraphs.<id>`.
|
|
492
|
+
*/
|
|
493
|
+
function locateDiagramIssue(issue: PlayCheckIssueShape): PlayCheckIssueShape {
|
|
494
|
+
if (!isDiagramIssue(issue) || issue.node) return issue;
|
|
495
|
+
const node = /^docflow\.(?:nodes|subgraphs)\.([^.[\]]+)/.exec(
|
|
496
|
+
issue.path ?? '',
|
|
497
|
+
)?.[1];
|
|
498
|
+
return node ? { ...issue, node } : issue;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export type PlayCheckDiagramSummary = {
|
|
502
|
+
/** False when the play's `@mermaid` block did not compile. */
|
|
503
|
+
drawn: boolean;
|
|
504
|
+
boxes: number;
|
|
505
|
+
/** Boxes a `// @mermaid-node` annotation binds to a statement. */
|
|
506
|
+
bound: number;
|
|
507
|
+
/** Boxes declared `class … sketch`: drawn, never run. */
|
|
508
|
+
sketched: number;
|
|
509
|
+
errors: number;
|
|
510
|
+
warnings: number;
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
function summarizeDiagram(
|
|
514
|
+
docflow: PlayCheckCompactDocflow | undefined,
|
|
515
|
+
issues: PlayCheckIssueShape[],
|
|
516
|
+
): PlayCheckDiagramSummary | undefined {
|
|
517
|
+
const diagramIssues = issues.filter(
|
|
518
|
+
(issue) => isDiagramIssue(issue) && !isOptionalDiagramNudge(issue),
|
|
519
|
+
);
|
|
520
|
+
if (!docflow && diagramIssues.length === 0) return undefined;
|
|
521
|
+
const nodes = docflow?.nodes ?? [];
|
|
522
|
+
return {
|
|
523
|
+
drawn: Boolean(docflow),
|
|
524
|
+
boxes: nodes.length,
|
|
525
|
+
bound: nodes.filter((node) => node.line !== undefined).length,
|
|
526
|
+
sketched: nodes.filter((node) => node.sketch).length,
|
|
527
|
+
errors: diagramIssues.filter((issue) => issue.severity === 'error').length,
|
|
528
|
+
warnings: diagramIssues.filter((issue) => issue.severity === 'warning')
|
|
529
|
+
.length,
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** `errors` and `warnings` as issues, skipping any an issue already states. */
|
|
534
|
+
function foldDiagnostics(compact: CompactPlayCheckResult) {
|
|
535
|
+
const issues = [...compact.issues];
|
|
536
|
+
for (const [severity, messages] of [
|
|
537
|
+
['error', compact.errors],
|
|
538
|
+
['warning', compact.warnings],
|
|
539
|
+
] as const) {
|
|
540
|
+
for (const message of messages) {
|
|
541
|
+
// A plain or message+hint mirror is dropped; appended repair guidance is
|
|
542
|
+
// not, and structured hints/valid options stay on their issue.
|
|
543
|
+
const mirrored = issues.some(
|
|
544
|
+
(issue) =>
|
|
545
|
+
issue.severity === severity &&
|
|
546
|
+
(issue.message.trim() === message.trim() ||
|
|
547
|
+
[issue.message.trim(), issue.hint?.trim()]
|
|
548
|
+
.filter(Boolean)
|
|
549
|
+
.join(' ') === message.trim()),
|
|
550
|
+
);
|
|
551
|
+
if (!mirrored)
|
|
552
|
+
issues.push({ severity, message, code: 'check_diagnostic' });
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return distinctIssues(issues.map(locateDiagramIssue));
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* The diagram a reader gets: each box with its line; what it reads, writes and
|
|
560
|
+
* shows only on a box an issue is about, where the fix needs it.
|
|
561
|
+
*/
|
|
562
|
+
function presentDocflow(
|
|
563
|
+
docflow: PlayCheckCompactDocflow | undefined,
|
|
564
|
+
issues: PlayCheckIssueShape[],
|
|
565
|
+
): PlayCheckCompactDocflow | undefined {
|
|
566
|
+
if (!docflow) return undefined;
|
|
567
|
+
const flagged = new Set(issues.map((issue) => issue.node));
|
|
568
|
+
return {
|
|
569
|
+
...docflow,
|
|
570
|
+
nodes: docflow.nodes.map((node) => {
|
|
571
|
+
if (flagged.has(node.id)) return node;
|
|
572
|
+
const { in: _in, out: _out, show: _show, ...box } = node;
|
|
573
|
+
return box;
|
|
574
|
+
}),
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/** The runtime limit, unless it is the standard one every play gets. */
|
|
579
|
+
function nonDefaultRuntimeLimit(value: unknown): RecordValue | undefined {
|
|
580
|
+
const limit = record(value);
|
|
581
|
+
if (!limit) return undefined;
|
|
582
|
+
const standard = STANDARD_PLAY_SANDBOX_RUNTIME_LIMITS as RecordValue;
|
|
583
|
+
return Object.keys(standard).every((key) => limit[key] === standard[key])
|
|
584
|
+
? undefined
|
|
585
|
+
: limit;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/** The recognized parts a reader acts on; empty parts and constants left out. */
|
|
589
|
+
function presentRecognized(
|
|
590
|
+
compact: CompactPlayCheckResult,
|
|
591
|
+
): RecordValue | undefined {
|
|
592
|
+
const { inputs, outputs, triggers: _triggers, tools, ...rest } =
|
|
593
|
+
compact.recognized ?? {};
|
|
594
|
+
const toolNames = strings(tools);
|
|
595
|
+
const recognized = withoutUndefined({
|
|
596
|
+
...Object.fromEntries(
|
|
597
|
+
Object.entries(rest).filter(
|
|
598
|
+
([, value]) =>
|
|
599
|
+
value !== undefined &&
|
|
600
|
+
value !== null &&
|
|
601
|
+
!(Array.isArray(value) && value.length === 0),
|
|
602
|
+
),
|
|
603
|
+
),
|
|
604
|
+
rowInputs: nonEmpty(array(inputs)),
|
|
605
|
+
outputs: compact.returnFields ?? nonEmpty(array(outputs)),
|
|
606
|
+
tools: toolNames.length ? { names: toolNames } : undefined,
|
|
607
|
+
});
|
|
608
|
+
return Object.keys(recognized).length ? recognized : undefined;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/** What a reader of one checked play gets, from the CLI or from MCP. */
|
|
612
|
+
export function presentPlayCheckResult(result: RecordValue) {
|
|
613
|
+
const compact = compactPlayCheckResult(result);
|
|
614
|
+
const issues = foldDiagnostics(compact);
|
|
615
|
+
return withoutUndefined({
|
|
616
|
+
valid: compact.valid,
|
|
617
|
+
issues,
|
|
618
|
+
diagram: summarizeDiagram(compact.docflow, issues),
|
|
619
|
+
input: playCheckInputFields(compact.inputSchema),
|
|
620
|
+
recognized: presentRecognized(compact),
|
|
621
|
+
triggers: compact.triggers ?? record(compact.recognized)?.triggers,
|
|
622
|
+
stages: compact.stages,
|
|
623
|
+
docflow: presentDocflow(compact.docflow, issues),
|
|
624
|
+
runtimeLimit: nonDefaultRuntimeLimit(compact.runtimeLimit),
|
|
625
|
+
limits: compact.limits,
|
|
626
|
+
runAdmission: compact.runAdmission,
|
|
627
|
+
toolGetterHints: nonEmpty(array(compact.toolGetterHints)),
|
|
628
|
+
sourceHash: compact.sourceHash,
|
|
629
|
+
artifactHash: compact.artifactHash,
|
|
630
|
+
graphHash: compact.graphHash,
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export type PresentedPlayCheckResult = ReturnType<
|
|
635
|
+
typeof presentPlayCheckResult
|
|
636
|
+
>;
|
|
@@ -14,6 +14,9 @@ const REPORTED_ABUSIVE_SIGNUP_DOMAINS = [
|
|
|
14
14
|
'jertom.com',
|
|
15
15
|
'temp-mail.lol',
|
|
16
16
|
'hidingpost.net',
|
|
17
|
+
// Temporary inboxes seen in the 2026-10 signup audit.
|
|
18
|
+
'18lover.com',
|
|
19
|
+
'westcast-systems.com',
|
|
17
20
|
] as const;
|
|
18
21
|
|
|
19
22
|
// Build once per module load. Authentication never needs an external lookup.
|
|
@@ -11,6 +11,30 @@ export function normalizeEmailDomain(value: string): string | null {
|
|
|
11
11
|
: null;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/** Providers that ignore dots in the local part, keyed to their canonical domain. */
|
|
15
|
+
const DOT_INSENSITIVE_DOMAINS = new Map([
|
|
16
|
+
['gmail.com', 'gmail.com'],
|
|
17
|
+
['googlemail.com', 'gmail.com'],
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The inbox an address delivers to: `+tag` suffixes are dropped and Gmail
|
|
22
|
+
* ignores dots, so every alias of one inbox shares one identity.
|
|
23
|
+
*/
|
|
24
|
+
export function mailboxIdentity(email?: string | null): string | undefined {
|
|
25
|
+
const normalized = email?.trim().toLowerCase();
|
|
26
|
+
if (!normalized) return undefined;
|
|
27
|
+
const atIndex = normalized.lastIndexOf('@');
|
|
28
|
+
if (atIndex <= 0) return normalized;
|
|
29
|
+
const local = normalized.slice(0, atIndex);
|
|
30
|
+
const domain = normalized.slice(atIndex + 1);
|
|
31
|
+
const untagged = local.split('+')[0] || local;
|
|
32
|
+
const dotInsensitiveDomain = DOT_INSENSITIVE_DOMAINS.get(domain);
|
|
33
|
+
return dotInsensitiveDomain
|
|
34
|
+
? `${untagged.replace(/\./g, '')}@${dotInsensitiveDomain}`
|
|
35
|
+
: `${untagged}@${domain}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
14
38
|
export function emailDomainCandidates(email: string): string[] {
|
|
15
39
|
const domain = normalizeEmailDomain(email.slice(email.lastIndexOf('@') + 1));
|
|
16
40
|
if (!email.includes('@') || !domain) return [];
|