@theoremjs/studio 0.3.4-next.528.g44c76f9 → 0.3.4-next.540.g67b727f
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/README.md +4 -1
- package/browser-connection.js +1 -1
- package/compile-workspace.js +26 -7
- package/compile.js +13 -2
- package/{example.d.ts → cookbooks/catalog.d.ts} +35 -5
- package/cookbooks/catalog.js +686 -0
- package/cookbooks/checks.d.ts +10 -0
- package/cookbooks/checks.js +93 -0
- package/cookbooks/exchanges.d.ts +11 -0
- package/cookbooks/exchanges.js +13 -0
- package/cookbooks/fixtures/research.trace.json +4455 -0
- package/cookbooks/mod.d.ts +8 -0
- package/cookbooks/mod.js +5 -0
- package/cookbooks/project.d.ts +66 -0
- package/cookbooks/project.js +195 -0
- package/cookbooks/providers.d.ts +165 -0
- package/cookbooks/providers.js +289 -0
- package/cookbooks/sources.d.ts +10 -0
- package/cookbooks/sources.js +125 -0
- package/cookbooks/tools.d.ts +23 -0
- package/{concierge-demo.js → cookbooks/tools.js} +428 -42
- package/map.js +3 -1
- package/mod.d.ts +3 -3
- package/mod.js +2 -3
- package/package.json +4 -4
- package/page/assets/{Banner-BhKnM-76.js → Banner-BwxDeFY1.js} +2 -2
- package/page/assets/{ConsoleFrame-CnGU8SiE.js → ConsoleFrame-Dewh6VXK.js} +1 -1
- package/page/assets/{ContextMenu-G2oYmfwG.js → ContextMenu-0p_1Utr-.js} +2 -2
- package/page/assets/{ToolResultCharts-DpaHoQFj.js → ToolResultCharts-ei_o_wTg.js} +1 -1
- package/page/assets/{TraceInspector-Bo0PzFVf.js → TraceInspector-DyQAWqOG.js} +1 -1
- package/page/assets/{TraceOverview-CM-sd2zM.js → TraceOverview-BawPHDUZ.js} +1 -1
- package/page/assets/{_virtual_studio-type-sources-DVbxNwnP.js → _virtual_studio-type-sources-C1mRXxbj.js} +29 -250
- package/page/assets/browser-engine-BBhaQ73h.js +11 -0
- package/page/assets/browser-transport-BMGb5bKR.js +47 -0
- package/page/assets/{compile-egress-BRGW9qfO.js → compile-egress-C3etX-3o.js} +1 -1
- package/page/assets/{crypto-BAY2nUlu.js → crypto-Dd6XxhqK.js} +1 -1
- package/page/assets/{encode-files-BSTfq_Gp.js → encode-files-CiyHxnUC.js} +1 -1
- package/page/assets/{export-agent-CtklkKZk.js → export-agent-CIOzkXW7.js} +2 -2
- package/page/assets/{guardrail-tester-BXROlU1L.js → guardrail-tester-Vn3HjOBN.js} +1 -1
- package/page/assets/host-patterns-F-KZIzkF.js +1 -0
- package/page/assets/{index-DbHspDC4.js → index-CQx3WisY.js} +120 -72
- package/page/assets/{live-ingress-qi-y5uvH.js → live-ingress-OuSlQ6q7.js} +1 -1
- package/page/assets/{live-messages-DIf_R-NT.js → live-messages-BNhCuiuF.js} +1 -1
- package/page/assets/reader-BT_YeHdq.js +7 -0
- package/page/assets/shaped-data-DYOBdvLJ.js +20 -0
- package/page/assets/{stub-4m0tKRlG.js → stub-DPcZtI0s.js} +78 -40
- package/page/assets/{studio-code-pane-Dt3MWPBE.js → studio-code-pane-CTaPxpwn.js} +3 -3
- package/page/assets/{studio-console-4PMBDYuu.js → studio-console-D2-0qGXG.js} +1 -1
- package/page/assets/{studio-decision-BiN_FO02.js → studio-decision-DjkIYfPm.js} +1 -1
- package/page/assets/{studio-embedding-C7gIUtxM.js → studio-embedding-IRaxgsCF.js} +1 -1
- package/page/assets/{studio-host-console-DOBHkxDj.js → studio-host-console-CpbWUasd.js} +2 -2
- package/page/assets/{studio-labels-Dh_rsQs7.js → studio-labels-7mSwqgwb.js} +1 -1
- package/page/assets/{studio-live-xPsQmJyQ.js → studio-live-DO8aNuBt.js} +1 -1
- package/page/assets/studio-map-GD9XCa23.js +1 -0
- package/page/assets/studio-trace-replay-Bx2YreVs.js +2 -0
- package/page/assets/{studio-type-checker-CHFs7A7H.js → studio-type-checker-B5DVxAZ0.js} +1 -1
- package/page/assets/tool-schema-CxLtS_Zt.js +17 -0
- package/page/assets/{trace-record-D9wgX8kq.js → trace-record-B2MF8flo.js} +1 -1
- package/page/assets/tree-Bi2FOU_h.js +3 -0
- package/page/assets/{turn-client-BWO4ocVM.js → turn-client-BCi5WnI6.js} +2 -2
- package/page/assets/types-s-3wFTyD.js +1 -0
- package/page/assets/{use-one-call-ApIuuZX3.js → use-one-call-OZH6wzzP.js} +1 -1
- package/page/assets/workspace-BiCkglEt.js +1 -0
- package/page/index.html +17 -17
- package/policy.js +1 -1
- package/registrations.d.ts +7 -1
- package/replay.d.ts +11 -0
- package/replay.js +67 -11
- package/runtime-scope.js +27 -3
- package/server/draft-decide.d.ts +1 -1
- package/source.js +2 -1
- package/stub.js +1 -1
- package/surface.js +6 -3
- package/tools.js +12 -6
- package/types.d.ts +2 -0
- package/ui/lib/studio-examples.d.ts +6 -31
- package/ui/lib/studio-examples.js +30 -15
- package/ui/lib/studio-open.d.ts +4 -1
- package/ui/lib/studio-open.js +6 -5
- package/ui/lib/tree-map-layout.js +9 -1
- package/ui/profile-editor.js +9 -8
- package/ui/studio-screen.js +30 -18
- package/workspace.js +8 -2
- package/concierge-demo.d.ts +0 -17
- package/example.js +0 -363
- package/page/assets/browser-engine-BJYQz5d_.js +0 -11
- package/page/assets/browser-transport-YKpXhacP.js +0 -47
- package/page/assets/host-patterns-cSf1U25G.js +0 -1
- package/page/assets/reader-BkaAkeh0.js +0 -7
- package/page/assets/shaped-data-C4jsvipW.js +0 -20
- package/page/assets/studio-map-Cc4_9fe9.js +0 -1
- package/page/assets/studio-trace-replay-D5JoQXyY.js +0 -2
- package/page/assets/tool-schema-DpbtSZtQ.js +0 -17
- package/page/assets/tree-0OoOeHfS.js +0 -3
- package/page/assets/types-BRZU5tBz.js +0 -1
- package/page/assets/workspace-DJBP4Adw.js +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable item validators (`outputs.validation.items.*.check`) for cookbook profiles.
|
|
3
|
+
* Because functions cannot cross JSON in `StudioRunPayload`, `runtimeProfileDefinition`
|
|
4
|
+
* attaches the matching check by `profile.id` and list name when running a draft.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { ProfileItemCheck } from '@theoremjs/agents';
|
|
9
|
+
/** Resolves an item check function for a draft's list rule: the cookbook's check when known, else a pass-through. */
|
|
10
|
+
export declare function resolveDraftItemCheck(profileId: string, list: string): ProfileItemCheck;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable item validators (`outputs.validation.items.*.check`) for cookbook profiles.
|
|
3
|
+
* Because functions cannot cross JSON in `StudioRunPayload`, `runtimeProfileDefinition`
|
|
4
|
+
* attaches the matching check by `profile.id` and list name when running a draft.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/** Text as it is compared: markup, typographic marks, case and spacing do not make different words. */
|
|
9
|
+
function comparable(text) {
|
|
10
|
+
return text
|
|
11
|
+
.normalize('NFKC')
|
|
12
|
+
.replace(/\\n/g, ' ')
|
|
13
|
+
.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
|
|
14
|
+
.replace(/[*_`#>\\]/g, '')
|
|
15
|
+
.replace(/[‘’“”"]/g, "'")
|
|
16
|
+
.replace(/[‐-―]/g, '-')
|
|
17
|
+
.replace(/\s+/g, ' ')
|
|
18
|
+
.trim()
|
|
19
|
+
.toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
function quotedWords(quote) {
|
|
22
|
+
return comparable(quote)
|
|
23
|
+
.replace(/^'+|'+$/g, '')
|
|
24
|
+
.replace(/[.,;:!?]+$/, '')
|
|
25
|
+
.trim();
|
|
26
|
+
}
|
|
27
|
+
/** How a source is named in a tool's output: an arXiv id, a Hub or GitHub owner/name, else the URL. */
|
|
28
|
+
function sourceKey(uri) {
|
|
29
|
+
const arxiv = /(\d{4}\.\d{4,5})/.exec(uri);
|
|
30
|
+
if (arxiv?.[1] && /arxiv/i.test(uri))
|
|
31
|
+
return arxiv[1];
|
|
32
|
+
const repo = /(?:huggingface\.co\/(?:datasets\/)?|github\.com\/)([\w.-]+\/[\w.-]+)/.exec(uri);
|
|
33
|
+
if (repo?.[1])
|
|
34
|
+
return repo[1].toLowerCase();
|
|
35
|
+
return uri
|
|
36
|
+
.replace(/[#?].*$/, '')
|
|
37
|
+
.replace(/\/$/, '')
|
|
38
|
+
.toLowerCase();
|
|
39
|
+
}
|
|
40
|
+
/** Each quotable tool result's text. DeepWiki's generated wiki (`ask_repo_docs`) is a lead, not a primary source. */
|
|
41
|
+
function resultsRead(results) {
|
|
42
|
+
return results
|
|
43
|
+
.filter(({ tool }) => tool !== 'ask_repo_docs')
|
|
44
|
+
.map(({ output }) => comparable(typeof output === 'string' ? output : JSON.stringify(output)));
|
|
45
|
+
}
|
|
46
|
+
const refused = (error) => ({ isValid: false, error });
|
|
47
|
+
/**
|
|
48
|
+
* Verifies each candidate in `research.scout`'s `research.reply`: a candidate with `basis === 'page'`
|
|
49
|
+
* must cite a URL a tool returned this turn and quote exact words from that tool result.
|
|
50
|
+
*/
|
|
51
|
+
function checkResearchCandidate(item, turn) {
|
|
52
|
+
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
|
53
|
+
return refused('Candidate must be an object.');
|
|
54
|
+
}
|
|
55
|
+
const candidate = item;
|
|
56
|
+
const basis = typeof candidate.basis === 'string' ? candidate.basis : '';
|
|
57
|
+
const url = typeof candidate.url === 'string' ? candidate.url : '';
|
|
58
|
+
const evidence = Array.isArray(candidate.evidence) ? candidate.evidence : [];
|
|
59
|
+
if (basis === 'page' && evidence.length === 0) {
|
|
60
|
+
return refused('A candidate based on a page needs that page and the exact words.');
|
|
61
|
+
}
|
|
62
|
+
const read = resultsRead(turn.toolResults);
|
|
63
|
+
if (basis === 'page' && url && !read.some((text) => text.includes(sourceKey(url)))) {
|
|
64
|
+
return refused('No tool returned this URL this turn. Find it with a tool, or set basis memory.');
|
|
65
|
+
}
|
|
66
|
+
for (const entry of evidence) {
|
|
67
|
+
if (!entry || typeof entry !== 'object')
|
|
68
|
+
continue;
|
|
69
|
+
const { uri = '', quote = '' } = entry;
|
|
70
|
+
const words = quotedWords(typeof quote === 'string' ? quote : '');
|
|
71
|
+
if (!words)
|
|
72
|
+
return refused('Each piece of evidence needs the exact words.');
|
|
73
|
+
const key = sourceKey(typeof uri === 'string' ? uri : '');
|
|
74
|
+
const fromIt = read.filter((text) => text.includes(key));
|
|
75
|
+
if (fromIt.length === 0) {
|
|
76
|
+
return refused(`No tool returned ${String(uri)} this turn. Cite a source you read, or read it first.`);
|
|
77
|
+
}
|
|
78
|
+
if (!fromIt.some((text) => text.includes(words))) {
|
|
79
|
+
return refused(`These words are not in what the tools returned for ${String(uri)}. Quote them exactly.`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { isValid: true };
|
|
83
|
+
}
|
|
84
|
+
const PASS_ITEM = () => ({ isValid: true });
|
|
85
|
+
const COOKBOOK_ITEM_CHECKS = {
|
|
86
|
+
'research.scout': {
|
|
87
|
+
candidates: checkResearchCandidate,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
/** Resolves an item check function for a draft's list rule: the cookbook's check when known, else a pass-through. */
|
|
91
|
+
export function resolveDraftItemCheck(profileId, list) {
|
|
92
|
+
return COOKBOOK_ITEM_CHECKS[profileId]?.[list] ?? PASS_ITEM;
|
|
93
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookbook opening exchanges: Studio `.trace.json` recordings projected with the same helpers
|
|
3
|
+
* Replay exchange and Continue live use. One truth — the file is the exchange.
|
|
4
|
+
*/
|
|
5
|
+
import type { TranscriptBlock } from '@theoremjs/agents/interface';
|
|
6
|
+
import type { CookbookId } from './catalog.ts';
|
|
7
|
+
/**
|
|
8
|
+
* The conversation a cookbook opens as history, from its recorded `.trace.json`. Undefined when
|
|
9
|
+
* the cookbook has no recording yet.
|
|
10
|
+
*/
|
|
11
|
+
export declare function cookbookOpening(id: CookbookId): TranscriptBlock[] | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { openingFromRecords, parseTraceRecords } from "../replay.js";
|
|
2
|
+
import researchTrace from './fixtures/research.trace.json' with { type: 'json' };
|
|
3
|
+
const OPENINGS = {
|
|
4
|
+
research: researchTrace,
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* The conversation a cookbook opens as history, from its recorded `.trace.json`. Undefined when
|
|
8
|
+
* the cookbook has no recording yet.
|
|
9
|
+
*/
|
|
10
|
+
export function cookbookOpening(id) {
|
|
11
|
+
const value = OPENINGS[id];
|
|
12
|
+
return value === undefined ? undefined : openingFromRecords(parseTraceRecords(value));
|
|
13
|
+
}
|