@promptdriven/runtime-client 0.0.0-stage → 1.0.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 (35) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +42 -2
  3. package/package.json +28 -4
  4. package/src/index.mjs +1 -0
  5. package/src/runtime/agent-ask.mjs +187 -0
  6. package/src/runtime/agent-chat.mjs +105 -0
  7. package/src/runtime/agent-coverage.mjs +97 -0
  8. package/src/runtime/agent-guide.mjs +152 -0
  9. package/src/runtime/agent-judge.mjs +71 -0
  10. package/src/runtime/agent-packet.mjs +62 -0
  11. package/src/runtime/agent-project.mjs +93 -0
  12. package/src/runtime/contract-refs.mjs +519 -0
  13. package/src/runtime/contracts.mjs +138 -0
  14. package/src/runtime/index.mjs +943 -0
  15. package/src/runtime/lint-call-preflight.mjs +19 -0
  16. package/src/runtime/lint-compatibility-display.mjs +62 -0
  17. package/src/runtime/product-composition.mjs +384 -0
  18. package/src/runtime/runtime-binding-plan.mjs +145 -0
  19. package/src/runtime/runtime-bindings.mjs +71 -0
  20. package/src/runtime/runtime-check-plan.mjs +411 -0
  21. package/src/runtime/runtime-client.mjs +6323 -0
  22. package/src/runtime/runtime-lint-receipt.mjs +25 -0
  23. package/src/runtime/runtime-markdown.mjs +215 -0
  24. package/src/runtime/runtime-outcome.mjs +407 -0
  25. package/src/runtime/runtime-output.mjs +714 -0
  26. package/src/runtime/runtime-preflight.mjs +3118 -0
  27. package/src/runtime/runtime-slots.mjs +391 -0
  28. package/src/runtime/runtime-workspace-migration.mjs +70 -0
  29. package/src/runtime/runtime-workspace.mjs +52 -0
  30. package/src/runtime/scenario-json.mjs +91 -0
  31. package/src/runtime/secret-redaction.mjs +53 -0
  32. package/src/runtime/try-doors.mjs +231 -0
  33. package/src/runtime/try-http.mjs +259 -0
  34. package/src/runtime/try-mcp.mjs +223 -0
  35. package/src/runtime/try-session.mjs +95 -0
@@ -0,0 +1,25 @@
1
+ // Generated from prompts/cli/runtime-lint-receipt.prompt.md.
2
+ const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
3
+ const text = value => typeof value === 'string' && value.trim().length > 0;
4
+ const knownEngine = value => text(value) && value.trim().toLowerCase() !== 'unknown';
5
+ const keys = ['root', 'origin', 'login', 'user_id', 'source_sha256', 'authored_sha256', 'tests', 'version', 'selected_cap'];
6
+ function validScope(scope) {
7
+ return object(scope) && Object.keys(scope).length === keys.length && keys.every(key => Object.hasOwn(scope, key))
8
+ && ['root', 'origin', 'login', 'user_id', 'version'].every(key => text(scope[key]))
9
+ && /^\d+$/.test(scope.user_id) && /^[a-f0-9]{64}$/.test(scope.source_sha256) && /^[a-f0-9]{64}$/.test(scope.authored_sha256)
10
+ && Array.isArray(scope.tests) && scope.tests.length > 0
11
+ && scope.tests.every((path, index) => text(path) && (index === 0 || scope.tests[index - 1] < path))
12
+ && (scope.selected_cap === null || Number.isInteger(scope.selected_cap) && scope.selected_cap >= 1 && scope.selected_cap <= 1000);
13
+ }
14
+
15
+ export function isRecentLintReceipt({ receipt, scope, now, engineSha = null }) {
16
+ if (!object(receipt) || receipt.schema_version !== 'pdd.lint-receipt.v1'
17
+ || !validScope(scope) || !validScope(receipt.scope) || !knownEngine(receipt.engine_sha)
18
+ || !Number.isFinite(now) || !Number.isFinite(receipt.received_at)
19
+ || now < receipt.received_at || now - receipt.received_at > 600_000
20
+ // Only a known current engine equal to the receipt's engine allows reuse; unknown cannot prove no deployment.
21
+ || !knownEngine(engineSha) || engineSha !== receipt.engine_sha) return false;
22
+ return keys.every(key => key === 'tests'
23
+ ? scope.tests.length === receipt.scope.tests.length && scope.tests.every((path, index) => path === receipt.scope.tests[index])
24
+ : scope[key] === receipt.scope[key]);
25
+ }
@@ -0,0 +1,215 @@
1
+ // Generated from prompts/cli/runtime-markdown.prompt.md (sha256: 5d52e1ed1555d7536693377ef187f47539910ed57d32d8eded79f46960b3b483).
2
+ export function markdownDefinitions(text) {
3
+ const definitions = new Map();
4
+ for (const match of text.matchAll(/^ {0,3}\[([^\]\n]+)\]:[ \t]*(?:<([^>\n]+)>|(\S+))/gm)) {
5
+ const id = match[1].trim().replace(/\s+/g, ' ').toLowerCase();
6
+ if (!definitions.has(id)) definitions.set(id, match[2] ?? match[3]);
7
+ }
8
+ return definitions;
9
+ }
10
+
11
+ function markdownEscaped(text, index) {
12
+ let start = index;
13
+ while (start > 0 && text[start - 1] === '\\') start--;
14
+ return (index - start) % 2 === 1;
15
+ }
16
+
17
+ // Return local destinations without treating link labels or reference definitions as file paths.
18
+ export function markdownLinks(text, definitions, imagesOnly = false) {
19
+ const paths = [];
20
+ const inline = /(!?)\[[^\]\n]*\]\([ \t]*/g;
21
+ for (let match; (match = inline.exec(text));) {
22
+ if (markdownEscaped(text, match.index + match[1].length)) {
23
+ inline.lastIndex = match.index + match[1].length + 1;
24
+ continue;
25
+ }
26
+ if (imagesOnly && (!match[1] || markdownEscaped(text, match.index))) continue;
27
+ let index = match.index + match[0].length, path = '', depth = 0;
28
+ if (text[index] === '<') {
29
+ const end = text.indexOf('>', index + 1);
30
+ if (end >= 0) paths.push(text.slice(index + 1, end));
31
+ continue;
32
+ }
33
+ for (; index < text.length; index++) {
34
+ const char = text[index];
35
+ if (char === '\\' && index + 1 < text.length) { path += text[++index]; continue; }
36
+ if (/\s/.test(char) || (char === ')' && depth === 0)) break;
37
+ if (char === '(') depth++;
38
+ if (char === ')') depth--;
39
+ path += char;
40
+ }
41
+ if (path) paths.push(path);
42
+ }
43
+ const reference = /(!?)\[([^\]\n]+)\](?:\[([^\]\n]*)\])?/g;
44
+ for (let match; (match = reference.exec(text));) {
45
+ if (markdownEscaped(text, match.index + match[1].length)) {
46
+ reference.lastIndex = match.index + match[1].length + 1;
47
+ continue;
48
+ }
49
+ if (imagesOnly && (!match[1] || markdownEscaped(text, match.index))) continue;
50
+ const following = text[match.index + match[0].length];
51
+ if (following === '(' || following === ':') continue;
52
+ const target = definitions.get((match[3] || match[2]).trim().replace(/\s+/g, ' ').toLowerCase());
53
+ if (target) paths.push(target);
54
+ }
55
+ return paths;
56
+ }
57
+
58
+ // Consume existing block containers, without treating fence content as new markup.
59
+ // A quote needs its marker on every code line; a list needs its content indent.
60
+ function markdownContainerLine(line, containers) {
61
+ let matched = 0;
62
+ for (const indent of containers) {
63
+ if (indent === '>') {
64
+ const quote = /^ {0,3}> ?/.exec(line);
65
+ if (!quote) break;
66
+ line = line.slice(quote[0].length);
67
+ } else {
68
+ const spaces = /^ */.exec(line)[0].length;
69
+ if (line.trim() && spaces < indent) break;
70
+ line = line.slice(Math.min(spaces, indent));
71
+ }
72
+ matched++;
73
+ }
74
+ return { line, matched };
75
+ }
76
+
77
+ // Discovery sees prose only; preserve offsets and newlines without changing captured bytes.
78
+ export function markdownSectionText(text) {
79
+ const parts = [], inline = /`+|<!--|</g;
80
+ const opaque = /<(?:[A-Za-z][A-Za-z0-9-]*(?:[ \t\r\n]+[A-Za-z_:][A-Za-z0-9_.:-]*(?:[ \t\r\n]*=[ \t\r\n]*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*[ \t\r\n]*\/?|\/[A-Za-z][A-Za-z0-9-]*[ \t\r\n]*|[A-Za-z][A-Za-z0-9+.-]{1,31}:[^\x00-\x20<>]*|[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*)>/y;
81
+ let containers = [], fence = null, comment = false, indented = false, copied = 0, paragraph = false;
82
+ let scopeStart = null, scopeEnd = 0;
83
+ const mask = (start, end) => {
84
+ parts.push(text.slice(copied, start), text.slice(start, end).replace(/[^\r\n]/g, ' '));
85
+ copied = end;
86
+ };
87
+ // Inline parsing belongs to one leaf block. A matching run in a later
88
+ // paragraph, heading or container cannot turn intervening prose into code.
89
+ const flush = () => {
90
+ if (scopeStart === null) return;
91
+ inline.lastIndex = scopeStart;
92
+ for (let match; (match = inline.exec(text)) && match.index < scopeEnd;) {
93
+ let tokenStart = match.index, token = match[0], slashes = 0;
94
+ for (let index = tokenStart - 1; index >= scopeStart && text[index] === '\\'; index--) slashes++;
95
+ if (slashes % 2) {
96
+ if (token === '<!--' || token.length === 1) continue;
97
+ // An escape consumes one punctuation character, not the entire run.
98
+ tokenStart++; token = token.slice(1);
99
+ }
100
+ if (token === '<') {
101
+ // Valid tags/autolinks consume their own backticks before code-opener
102
+ // lexing. Leave their bytes available to the existing capture policy.
103
+ opaque.lastIndex = tokenStart;
104
+ if (opaque.test(text) && opaque.lastIndex <= scopeEnd) inline.lastIndex = opaque.lastIndex;
105
+ continue;
106
+ }
107
+ let closeEnd;
108
+ if (token === '<!--') {
109
+ const close = text.indexOf('-->', inline.lastIndex);
110
+ if (close < 0 || close + 3 > scopeEnd) continue;
111
+ closeEnd = close + 3;
112
+ } else {
113
+ const closing = new RegExp('(?<!`)`{' + token.length + '}(?!`)', 'g');
114
+ closing.lastIndex = inline.lastIndex;
115
+ const close = closing.exec(text);
116
+ if (!close || close.index + close[0].length > scopeEnd) continue;
117
+ // Backslashes have no escape meaning inside an actual code span.
118
+ closeEnd = close.index + close[0].length;
119
+ }
120
+ mask(tokenStart, closeEnd);
121
+ inline.lastIndex = closeEnd;
122
+ }
123
+ scopeStart = null;
124
+ };
125
+ for (const row of text.matchAll(/[^\r\n]*(?:\r\n|[\r\n]|$)/g)) {
126
+ if (!row[0]) continue;
127
+ const original = row[0].replace(/[\r\n]+$/, '');
128
+ const start = row.index, end = start + original.length;
129
+ {
130
+ // Tabs affect Markdown indentation only. This view is never captured.
131
+ let column = 0;
132
+ const expanded = original.replace(/[^\t]|\t/g, char => {
133
+ const width = char === '\t' ? 4 - column % 4 : 1;
134
+ column += width;
135
+ return char === '\t' ? ' '.repeat(width) : char;
136
+ });
137
+ let { line, matched } = markdownContainerLine(expanded, containers);
138
+ const thematic = /^ {0,3}(?:(?:\* *){3,}|(?:- *){3,}|(?:_ *){3,})$/;
139
+ const item = /^ {0,3}([-+*]|[0-9]{1,9}[.)]) +(\S.*)$/.exec(line);
140
+ const fenceStart = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
141
+ const validFence = fenceStart && !(fenceStart[1][0] === '`' && fenceStart[2].includes('`'));
142
+ // Only HTML block types that can interrupt a paragraph split its inline
143
+ // scope; ordinary angle prose and custom inline tags do not.
144
+ const htmlStart = /^ {0,3}<(?:!--|\?|![A-Z]|!\[CDATA\[|(?:pre|script|style|textarea)(?=[\t >]|$))/i.test(line)
145
+ || /^ {0,3}<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?=[\t >]|\/>|$)/i.test(line);
146
+ const startsBlock = /^ {0,3}(?:>|#{1,6}(?: |$))/.test(line) || validFence || htmlStart || thematic.test(line)
147
+ || (item && (!paragraph || !/^[0-9]/.test(item[1]) || /^1[.)]$/.test(item[1])
148
+ || (matched < containers.length && containers[matched] !== '>')));
149
+ // Lazy paragraph continuation keeps its parent containers available for a
150
+ // later indented fence. Code itself never permits lazy continuation.
151
+ const lazy = matched < containers.length && !fence && !comment && !indented && paragraph && line.trim() && !startsBlock;
152
+ const boundary = !line.trim() || startsBlock || /^ {0,3}(?:=+|-+) *$/.test(line)
153
+ || (!lazy && matched < containers.length);
154
+ if (boundary) flush();
155
+ if (!lazy && matched < containers.length) { fence = null; comment = false; indented = false; paragraph = false; }
156
+ if (!lazy) containers = containers.slice(0, matched);
157
+ if (fence) {
158
+ mask(start, end);
159
+ const close = /^ {0,3}(`{3,}|~{3,}) *$/.exec(line);
160
+ if (close && close[1][0] === fence[0] && close[1].length >= fence.length) fence = null;
161
+ continue;
162
+ }
163
+ if (comment) {
164
+ const close = original.indexOf('-->');
165
+ mask(start, close < 0 ? end : start + close + 3);
166
+ if (close < 0) continue;
167
+ comment = false;
168
+ scopeStart = start + close + 3; scopeEnd = end;
169
+ flush();
170
+ continue;
171
+ }
172
+ // Code starts only at a leaf boundary. Its indentation belongs to the
173
+ // existing container; markup inside it cannot open another container.
174
+ if ((indented && !line.trim()) || (!paragraph && /^ {4}/.test(line))) {
175
+ indented = true; mask(start, end); continue;
176
+ }
177
+ indented = false;
178
+ // Start containers only outside code; a list's continuation width belongs
179
+ // to its item, so a sibling marker or dedent ends an unclosed example.
180
+ for (; !lazy;) {
181
+ const quote = /^ {0,3}> ?/.exec(line);
182
+ if (quote) { containers.push('>'); line = line.slice(quote[0].length); paragraph = false; continue; }
183
+ const list = /^( {0,3})([-+*]|[0-9]{1,9}[.)])( +|$)/.exec(line);
184
+ if (!list || thematic.test(line)) break;
185
+ const rest = line.slice(list[0].length);
186
+ if (paragraph && (!rest.trim() || (/^[0-9]/.test(list[2]) && !/^1[.)]$/.test(list[2])))) break;
187
+ const padding = rest.trim() && list[3].length <= 4 ? list[3].length : 1;
188
+ const indent = list[1].length + list[2].length + padding;
189
+ containers.push(indent); line = line.slice(indent); paragraph = false;
190
+ }
191
+ if (!paragraph && /^ {4}/.test(line)) {
192
+ indented = true; mask(start, end); continue;
193
+ }
194
+ const opening = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
195
+ if (!lazy && opening && !(opening[1][0] === '`' && opening[2].includes('`'))) {
196
+ fence = opening[1]; paragraph = false; mask(start, end); continue;
197
+ }
198
+ if (/^ {0,3}<!--/.test(line)) {
199
+ const opening = original.indexOf('<!--'), close = original.indexOf('-->', opening + 4);
200
+ mask(start + opening, close < 0 ? end : start + close + 3);
201
+ comment = close < 0; paragraph = false;
202
+ if (!comment) { scopeStart = start + close + 3; scopeEnd = end; flush(); }
203
+ continue;
204
+ }
205
+ const definition = !paragraph && /^ {0,3}\[[^\]]+\]:/.test(line);
206
+ paragraph = Boolean(line.trim()) && !thematic.test(line) && !definition && !htmlStart
207
+ && !/^ {0,3}(?:#{1,6}(?: |$)|=+ *$)/.test(line);
208
+ }
209
+ if (scopeStart === null) scopeStart = start;
210
+ scopeEnd = end;
211
+ if (!paragraph) flush();
212
+ }
213
+ flush();
214
+ return parts.join('') + text.slice(copied);
215
+ }