@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
|
@@ -1,18 +1,76 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Kn as e,_r as t,i as n,o as r}from"./tool-schema-CxLtS_Zt.js";var i=e.filter(e=>e===`image/*`||e===`application/pdf`||e.startsWith(`text/`)),a=t.filter(e=>e===`audio/*`),o=`{
|
|
2
2
|
"User-Agent": "TheoremStudio/1.0 (travel demo; +https://github.com/masudl-hub/theoremai)"
|
|
3
|
-
}`,s
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
}`,s=`{
|
|
4
|
+
"Accept": "application/vnd.github.raw",
|
|
5
|
+
"User-Agent": "TheoremStudio/1.0 (research scout; +https://github.com/masudl-hub/theoremai)"
|
|
6
|
+
}`,c=[`get_cat_fact`,`tell_joke`,`get_advice`,`random_dog_image`],l={geocode_city:{name:`Paris`},search_places:{q:`Paris`,limit:1},reverse_geocode:{lat:48.85,lon:2.35},get_weather:{latitude:48.85,longitude:2.35},get_sun_times:{lat:48.85,lng:2.35},convert_currency:{from:`USD`,to:`EUR`,amount:100},wikipedia_summary:{title:`Paris`},archive_text_search:{q:`mediatype:texts AND travel`,rows:1},lookup_postal_code:{country:`us`,postal:`90210`},get_pokemon:{name:`pikachu`},read_repo_file:{owner:`denoland`,repo:`std`,path:`README.md`},lookup_package:{name:`zod`},get_cat_fact:{},tell_joke:{},get_advice:{},random_dog_image:{},list_arxiv:{search_query:`all:"episodic memory" AND all:"language model"`},search_models:{search:`retrieval embedding`},search_datasets:{search:`long context memory`},read_model_card:{owner:`sentence-transformers`,name:`all-MiniLM-L6-v2`,question:`What is the embedding dimension?`},read_dataset_card:{owner:`THUDM`,name:`LongBench`,question:`What context lengths are tested?`},search_github:{q:`llm episodic memory`},read_readme:{owner:`mem0ai`,repo:`mem0`,question:`How are memories stored?`}};function u(e){return l[e]}var d=`nominatim.openstreetmap.org, geocoding-api.open-meteo.com, api.open-meteo.com, api.frankfurter.dev, api.sunrise-sunset.org, api.zippopotam.us, en.wikipedia.org, archive.org, pokeapi.co, dog.ceo, api.adviceslip.com, catfact.ninja, official-joke-api.appspot.com, mcp.deepwiki.com, mcp.context7.com, learn.microsoft.com, docs.mcp.cloudflare.com, knowledge-mcp.global.api.aws, huggingface.co, mcp.docs.astro.build, mcp.exa.ai, raw.githubusercontent.com, registry.npmjs.org, export.arxiv.org, api.github.com`,f=`mcp.exa.ai, export.arxiv.org, huggingface.co, api.github.com, raw.githubusercontent.com, mcp.context7.com, mcp.deepwiki.com`;function p(){return{text:!0,attachmentsAccept:i,voiceAccept:a,maxFiles:5,maxBytes:10485760,maxTurnBytes:26214400}}var m=`"question": { "type": "string", "minLength": 1, "description": "What you need from this source, as one specific question.", "examples": ["What datasets are evaluated?"] }`,h=[{id:`tool-read-pages`,data:{toolName:`read_pages`,activity:`Reading {urls.0}`,activityPast:`when urls.length is 1: Read {urls.0}
|
|
7
|
+
Read {urls.length} pages
|
|
8
|
+
Read pages`,activityFailed:`Could not read {urls.0|that page}`,request:`read {urls.0}`,toolType:`mcp`,description:`Read up to three web pages by URL via Exa. Pass the specific question you are reading them for.`,category:`research`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],serverUrl:`https://mcp.exa.ai/mcp`,mcpToolName:`web_fetch_exa`,inputJson:`{
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"urls": { "type": "array", "items": { "type": "string", "format": "uri" }, "minItems": 1, "maxItems": 3, "description": "Web page URLs to read", "examples": [["https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2"]] },
|
|
12
|
+
"maxCharacters": { "type": "integer", "maximum": 8000, "description": "Max characters per page", "examples": [8000] },
|
|
13
|
+
${m}
|
|
14
|
+
},
|
|
15
|
+
"required": ["urls", "question"]
|
|
16
|
+
}`,outputJson:`{ "type": "string", "description": "Extracted passages from the requested pages" }`}},{id:`tool-list-arxiv`,data:{toolName:`list_arxiv`,activity:`Searching arXiv for {search_query}`,activityPast:`Searched arXiv for {search_query}`,activityFailed:`Could not search arXiv for {search_query|that query}`,request:`search arXiv for {search_query}`,toolType:`http`,description:`Fetch the newest arXiv submissions matching an arXiv query (e.g. all:"episodic memory" AND all:"language model").`,category:`research`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],endpoint:`https://export.arxiv.org/api/query?sortBy=submittedDate&sortOrder=descending&max_results=10`,method:`GET`,queryParams:[`search_query`],inputJson:`{
|
|
17
|
+
"type": "object",
|
|
18
|
+
"properties": {
|
|
19
|
+
"search_query": { "type": "string", "minLength": 1, "description": "arXiv query expression", "examples": ["all:\\"episodic memory\\" AND all:\\"language model\\""] }
|
|
20
|
+
},
|
|
21
|
+
"required": ["search_query"]
|
|
22
|
+
}`,outputJson:`{ "type": "string", "description": "Atom XML feed of matching arXiv preprints" }`}},{id:`tool-search-models`,data:{toolName:`search_models`,activity:`Searching Hugging Face models for {search}`,activityPast:`Found {length} hits for {search}
|
|
23
|
+
Found hits for {search|that query}`,activityFailed:`Could not search models for {search|that query}`,request:`search Hugging Face models for {search}`,toolType:`http`,description:`Search Hugging Face Hub models, most recently modified first.`,category:`research`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],endpoint:`https://huggingface.co/api/models?sort=lastModified&direction=-1&limit=15`,method:`GET`,queryParams:[`search`],inputJson:`{
|
|
24
|
+
"type": "object",
|
|
25
|
+
"properties": {
|
|
26
|
+
"search": { "type": "string", "minLength": 1, "description": "Model search terms", "examples": ["retrieval embedding"] }
|
|
27
|
+
},
|
|
28
|
+
"required": ["search"]
|
|
29
|
+
}`,outputJson:`{ "type": "array", "items": { "type": "object" } }`}},{id:`tool-search-datasets`,data:{toolName:`search_datasets`,activity:`Searching Hugging Face datasets for {search}`,activityPast:`Found {length} hits for {search}
|
|
30
|
+
Found hits for {search|that query}`,activityFailed:`Could not search datasets for {search|that query}`,request:`search Hugging Face datasets for {search}`,toolType:`http`,description:`Search Hugging Face Hub datasets, most recently modified first.`,category:`research`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],endpoint:`https://huggingface.co/api/datasets?sort=lastModified&direction=-1&limit=15`,method:`GET`,queryParams:[`search`],inputJson:`{
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"search": { "type": "string", "minLength": 1, "description": "Dataset search terms", "examples": ["long context memory"] }
|
|
34
|
+
},
|
|
35
|
+
"required": ["search"]
|
|
36
|
+
}`,outputJson:`{ "type": "array", "items": { "type": "object" } }`}},{id:`tool-read-model-card`,data:{toolName:`read_model_card`,activity:`Reading model card {owner}/{name}`,activityPast:`Read model card {owner}/{name}`,activityFailed:`Could not read model card {owner}/{name}`,request:`read model card {owner}/{name}`,toolType:`http`,description:`Read a Hugging Face model card (README.md) by owner and model name.`,category:`research`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],endpoint:`https://huggingface.co/{owner}/{name}/raw/main/README.md`,method:`GET`,pathParams:[`owner`,`name`],inputJson:`{
|
|
37
|
+
"type": "object",
|
|
38
|
+
"properties": {
|
|
39
|
+
"owner": { "type": "string", "description": "Hub organisation or user", "examples": ["sentence-transformers"] },
|
|
40
|
+
"name": { "type": "string", "description": "Model repository name", "examples": ["all-MiniLM-L6-v2"] },
|
|
41
|
+
${m}
|
|
42
|
+
},
|
|
43
|
+
"required": ["owner", "name", "question"]
|
|
44
|
+
}`,outputJson:`{ "type": "string", "description": "Model card Markdown" }`}},{id:`tool-read-dataset-card`,data:{toolName:`read_dataset_card`,activity:`Reading dataset card {owner}/{name}`,activityPast:`Read dataset card {owner}/{name}`,activityFailed:`Could not read dataset card {owner}/{name}`,request:`read dataset card {owner}/{name}`,toolType:`http`,description:`Read a Hugging Face dataset card (README.md) by owner and dataset name.`,category:`research`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],endpoint:`https://huggingface.co/datasets/{owner}/{name}/raw/main/README.md`,method:`GET`,pathParams:[`owner`,`name`],inputJson:`{
|
|
45
|
+
"type": "object",
|
|
46
|
+
"properties": {
|
|
47
|
+
"owner": { "type": "string", "description": "Hub organisation or user", "examples": ["THUDM"] },
|
|
48
|
+
"name": { "type": "string", "description": "Dataset repository name", "examples": ["LongBench"] },
|
|
49
|
+
${m}
|
|
50
|
+
},
|
|
51
|
+
"required": ["owner", "name", "question"]
|
|
52
|
+
}`,outputJson:`{ "type": "string", "description": "Dataset card Markdown" }`}},{id:`tool-search-github`,data:{toolName:`search_github`,activity:`Searching GitHub for {q}`,activityPast:`Found {total_count} hits for {q}
|
|
53
|
+
Found hits for {q|that query}`,activityFailed:`Could not search GitHub for {q|that query}`,request:`search GitHub for {q}`,toolType:`http`,description:`Search public GitHub repositories, most recently updated first.`,category:`research`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],endpoint:`https://api.github.com/search/repositories?sort=updated&per_page=6`,method:`GET`,headersJson:s,queryParams:[`q`],inputJson:`{
|
|
54
|
+
"type": "object",
|
|
55
|
+
"properties": {
|
|
56
|
+
"q": { "type": "string", "minLength": 1, "description": "GitHub repository search query", "examples": ["llm episodic memory"] }
|
|
57
|
+
},
|
|
58
|
+
"required": ["q"]
|
|
59
|
+
}`,outputJson:`{
|
|
60
|
+
"type": "object",
|
|
61
|
+
"properties": {
|
|
62
|
+
"total_count": { "type": "number" },
|
|
63
|
+
"items": { "type": "array", "items": { "type": "object" } }
|
|
64
|
+
}
|
|
65
|
+
}`}},{id:`tool-read-readme`,data:{toolName:`read_readme`,activity:`Reading README of {owner}/{repo}`,activityPast:`Read README of {owner}/{repo}`,activityFailed:`Could not read README of {owner}/{repo}`,request:`read README of {owner}/{repo}`,toolType:`http`,description:`Read a public GitHub repository README by owner and repository name.`,category:`research`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],endpoint:`https://api.github.com/repos/{owner}/{repo}/readme`,method:`GET`,headersJson:s,pathParams:[`owner`,`repo`],inputJson:`{
|
|
66
|
+
"type": "object",
|
|
67
|
+
"properties": {
|
|
68
|
+
"owner": { "type": "string", "description": "GitHub owner", "examples": ["mem0ai"] },
|
|
69
|
+
"repo": { "type": "string", "description": "GitHub repository name", "examples": ["mem0"] },
|
|
70
|
+
${m}
|
|
71
|
+
},
|
|
72
|
+
"required": ["owner", "repo", "question"]
|
|
73
|
+
}`,outputJson:`{ "type": "string", "description": "Repository README Markdown" }`}},{id:`tool-geocode-city`,data:{toolName:`geocode_city`,activity:`Finding {name}`,activityPast:`Found {results.0.name}`,request:`find {name}`,toolType:`http`,description:`Resolve a city or place name to coordinates using the Open-Meteo geocoding API.`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],endpoint:`https://geocoding-api.open-meteo.com/v1/search?count=3`,method:`GET`,queryParams:[`name`],inputJson:`{
|
|
16
74
|
"type": "object",
|
|
17
75
|
"properties": {
|
|
18
76
|
"name": { "type": "string", "examples": ["Paris"], "description": "City or place name" }
|
|
@@ -156,7 +214,7 @@ Multimodal Understanding:
|
|
|
156
214
|
"postal": { "type": "string", "examples": ["90210"] }
|
|
157
215
|
},
|
|
158
216
|
"required": ["country", "postal"]
|
|
159
|
-
}`,outputJson:`{ "type": "object" }`}},{id:`tool-ask-deepwiki`,data:{toolName:`ask_repo_docs`,activity:`Checking the docs`,activityPast:`Checked the docs`,request:`check the docs`,toolType:`mcp`,description:`Ask questions about a public GitHub repo via DeepWiki MCP (Streamable HTTP).`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],serverUrl:`https://mcp.deepwiki.com/mcp`,mcpToolName:`ask_wiki_question`,inputJson:`{
|
|
217
|
+
}`,outputJson:`{ "type": "object" }`}},{id:`tool-ask-deepwiki`,data:{toolName:`ask_repo_docs`,activity:`Checking the docs`,activityPast:`Checked the docs`,activityFailed:`Could not check the docs`,request:`check the docs`,toolType:`mcp`,description:`Ask questions about a public GitHub repo via DeepWiki MCP (Streamable HTTP).`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],serverUrl:`https://mcp.deepwiki.com/mcp`,mcpToolName:`ask_wiki_question`,inputJson:`{
|
|
160
218
|
"type": "object",
|
|
161
219
|
"properties": {
|
|
162
220
|
"repoName": { "type": "string", "description": "The GitHub repo, as owner/repo", "examples": ["sveltejs/kit"] },
|
|
@@ -167,14 +225,14 @@ Multimodal Understanding:
|
|
|
167
225
|
"type": "object",
|
|
168
226
|
"properties": { "result": { "type": "string", "description": "Answer text from DeepWiki" } },
|
|
169
227
|
"required": ["result"]
|
|
170
|
-
}`}},{id:`tool-context7-resolve`,data:{toolName:`find_library`,activity:`Finding {libraryName}`,activityPast:`Found {libraryName}`,request:`find {libraryName}`,toolType:`mcp`,description:`Find a library's Context7 ID by name. Call before read_library_docs unless the user gave an ID like /vercel/next.js.`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],serverUrl:`https://mcp.context7.com/mcp`,mcpToolName:`resolve-library-id`,inputJson:`{
|
|
228
|
+
}`}},{id:`tool-context7-resolve`,data:{toolName:`find_library`,activity:`Finding {libraryName}`,activityPast:`Found {libraryName}`,activityFailed:`Could not find {libraryName|that library}`,request:`find {libraryName}`,toolType:`mcp`,description:`Find a library's Context7 ID by name. Call before read_library_docs unless the user gave an ID like /vercel/next.js.`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],serverUrl:`https://mcp.context7.com/mcp`,mcpToolName:`resolve-library-id`,inputJson:`{
|
|
171
229
|
"type": "object",
|
|
172
230
|
"properties": {
|
|
173
231
|
"libraryName": { "type": "string", "description": "The library's official name", "maxLength": 100, "examples": ["Next.js"] },
|
|
174
232
|
"query": { "type": "string", "description": "What the user wants to do with it", "maxLength": 500, "examples": ["Set up middleware"] }
|
|
175
233
|
},
|
|
176
234
|
"required": ["libraryName", "query"]
|
|
177
|
-
}`,outputJson:`{ "type": "string", "description": "Matching libraries and their Context7 IDs" }`}},{id:`tool-context7-docs`,data:{toolName:`read_library_docs`,activity:`Reading the {libraryId} docs`,activityPast:`Read the {libraryId} docs`,request:`read the {libraryId} docs`,toolType:`mcp`,description:`Up-to-date docs and code examples for one library from Context7, for one topic per call.`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],serverUrl:`https://mcp.context7.com/mcp`,mcpToolName:`query-docs`,inputJson:`{
|
|
235
|
+
}`,outputJson:`{ "type": "string", "description": "Matching libraries and their Context7 IDs" }`}},{id:`tool-context7-docs`,data:{toolName:`read_library_docs`,activity:`Reading the {libraryId} docs`,activityPast:`Read the {libraryId} docs`,activityFailed:`Could not read the {libraryId|library} docs`,request:`read the {libraryId} docs`,toolType:`mcp`,description:`Up-to-date docs and code examples for one library from Context7, for one topic per call.`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],serverUrl:`https://mcp.context7.com/mcp`,mcpToolName:`query-docs`,inputJson:`{
|
|
178
236
|
"type": "object",
|
|
179
237
|
"properties": {
|
|
180
238
|
"libraryId": { "type": "string", "description": "A Context7 ID from find_library, like /vercel/next.js", "maxLength": 200, "examples": ["/reactjs/react.dev"] },
|
|
@@ -299,7 +357,7 @@ Multimodal Understanding:
|
|
|
299
357
|
}
|
|
300
358
|
},
|
|
301
359
|
"required": ["search_results"]
|
|
302
|
-
}`}},{id:`tool-exa-search`,data:{toolName:`search_web`,activity:`Searching the web for {query}`,activityPast:`Searched the web for {query}`,request:`search the web for {query}`,toolType:`mcp`,description:`Search the web with Exa for current information, news, people, or companies. Describe the page you want, not just keywords.`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],serverUrl:`https://mcp.exa.ai/mcp`,mcpToolName:`web_search_exa`,inputJson:`{
|
|
360
|
+
}`}},{id:`tool-exa-search`,data:{toolName:`search_web`,activity:`Searching the web for {query}`,activityPast:`Searched the web for {query}`,activityFailed:`Could not search the web for {query|that query}`,request:`search the web for {query}`,toolType:`mcp`,description:`Search the web with Exa for current information, news, people, or companies. Describe the page you want, not just keywords.`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],serverUrl:`https://mcp.exa.ai/mcp`,mcpToolName:`web_search_exa`,inputJson:`{
|
|
303
361
|
"type": "object",
|
|
304
362
|
"properties": {
|
|
305
363
|
"query": { "type": "string", "description": "A description of the ideal page", "minLength": 1, "maxLength": 500, "examples": ["blog post comparing Cloudflare Workers and AWS Lambda cold starts"] },
|
|
@@ -312,7 +370,7 @@ Multimodal Understanding:
|
|
|
312
370
|
"loaded": { "type": "array", "items": { "type": "string" } }
|
|
313
371
|
},
|
|
314
372
|
"required": ["loaded"]
|
|
315
|
-
}`,stubOutputJson:JSON.stringify({loaded:[...
|
|
373
|
+
}`,stubOutputJson:JSON.stringify({loaded:[...c]})}},{id:`tool-weather-label`,data:{toolName:`weather_code_label`,activity:`Reading the forecast`,activityPast:`Forecast: {label}`,request:`read the forecast`,toolType:`function`,description:`Translate an Open-Meteo WMO weathercode into a short label.`,category:`demo`,access:`read-only`,permission:`auto`,loadTier:`T0`,paths:[`*`],inputJson:`{
|
|
316
374
|
"type": "object",
|
|
317
375
|
"properties": {
|
|
318
376
|
"weathercode": { "type": "integer", "description": "Open-Meteo WMO weather code", "examples": [2] }
|
|
@@ -448,24 +506,4 @@ Multimodal Understanding:
|
|
|
448
506
|
"peerDependencies": { "type": "object" }
|
|
449
507
|
},
|
|
450
508
|
"required": ["name", "version"]
|
|
451
|
-
}`}}],
|
|
452
|
-
|
|
453
|
-
Communication Standards:
|
|
454
|
-
- Readable Formatting: Use markdown where it helps the reader: short headings, bullet lists, code blocks for code, and tables for side-by-side comparisons.
|
|
455
|
-
- Answer First: Lead with the recommendation, then the reasons and the trade-offs. Name what you could not confirm.
|
|
456
|
-
|
|
457
|
-
Tool & Fact Grounding:
|
|
458
|
-
- Absolute Grounding: Ground claims about a library, a repository, a package version, or a cloud service in the tools before answering. Never invent an API, a version, or a default.
|
|
459
|
-
- Silent Execution: Never narrate tool calls or announce function names. Work findings into the answer.
|
|
460
|
-
- Complete Resolution: Finish multi-step research before you answer.
|
|
461
|
-
|
|
462
|
-
Audio briefings:
|
|
463
|
-
- When asked for a podcast, a briefing, or anything to listen to, write a short spoken script of what you found, in plain sentences with no markdown, and pass it to narrate. Then say in one line what the briefing covers.`,v=`Role: Elite, charismatic travel concierge, on a call.
|
|
464
|
-
|
|
465
|
-
Speaking:
|
|
466
|
-
- Speak in short, natural sentences. No lists, no markdown, no reading out of addresses, or codes unless asked.
|
|
467
|
-
- Give the recommendation first, then offer one next step.
|
|
468
|
-
|
|
469
|
-
Tool & Fact Grounding:
|
|
470
|
-
- Ground weather, currency, distances, and places in the tools before you answer. Never invent live data.
|
|
471
|
-
- Never name a tool or say that you are calling one.`;function y(){return p}function b(e){let t={},n=e.properties??{};for(let[e,r]of Object.entries(n)){let n=r.type;t[e]=n===`number`||n===`integer`?0:n===`boolean`?!1:n===`array`?[]:n===`object`?{}:`studio:${e}`}return Object.keys(t).length||(t.result=`studio stub`),t}function x(e,n){let i=l(e.trim());if(i)return i;let a=t(n,`Input`);return a.ok?r(a.schema):void 0}export{h as a,g as c,y as d,_ as i,v as l,b as n,d as o,u as r,m as s,x as t,f as u};
|
|
509
|
+
}`}}],g=[`search_web`,`read_pages`,`list_arxiv`,`search_models`,`search_datasets`,`read_model_card`,`read_dataset_card`,`search_github`,`read_readme`,`find_library`,`read_library_docs`,`ask_repo_docs`],_=[`read_pages`,`read_model_card`,`read_dataset_card`,`read_readme`,`read_library_docs`],v=[`geocode_city`,`search_places`,`reverse_geocode`,`lookup_postal_code`,`haversine_distance`,`get_weather`,`weather_code_label`,`get_sun_times`,`convert_currency`,`convert_units`,`plan_day`,`trip_budget_estimate`,`packing_suggestions`,`search_web`,`wikipedia_summary`,`discover_tools`,...c],y=[`ask_repo_docs`,`read_repo_file`,`lookup_package`,`find_library`,`read_library_docs`,`search_microsoft_docs`,`search_cloudflare_docs`,`list_aws_regions`,`search_aws_docs`,`search_hugging_face`,`search_astro_docs`,`search_web`,`wikipedia_summary`],b=[`get_weather`,`search_places`,`convert_currency`,`ask_repo_docs`,`random_dog_image`,`get_pokemon`,`archive_text_search`];function x(){return h}function S(e){let t={},n=e.properties??{};for(let[e,r]of Object.entries(n)){let n=r.type;t[e]=n===`number`||n===`integer`?0:n===`boolean`?!1:n===`array`?[]:n===`object`?{}:`studio:${e}`}return Object.keys(t).length||(t.result=`studio stub`),t}function C(e,t){let i=u(e.trim());if(i)return i;let a=n(t,`Input`);return a.ok?r(a.schema):void 0}export{v as a,g as c,x as d,y as i,f as l,S as n,b as o,d as r,_ as s,C as t,p as u};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/studio-monaco-xfyfezQS.js","assets/editor.api-Cd3ViPQa.js","assets/preload-helper-DpV6A1kQ.js","assets/editor-DjpsE8to.css","assets/studio-monaco-CbKf90i6.css","assets/register-CDgivxvX.js","assets/studio-type-checker-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{t as r}from"./preload-helper-DpV6A1kQ.js";import{D as i,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/studio-monaco-xfyfezQS.js","assets/editor.api-Cd3ViPQa.js","assets/preload-helper-DpV6A1kQ.js","assets/editor-DjpsE8to.css","assets/studio-monaco-CbKf90i6.css","assets/register-CDgivxvX.js","assets/studio-type-checker-B5DVxAZ0.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{t as r}from"./preload-helper-DpV6A1kQ.js";import{D as i,Gt as a,T as o,Wt as s,Yn as c,k as l,vr as u}from"./tool-schema-CxLtS_Zt.js";import{En as d,Sn as f,qt as p}from"./shaped-data-DYOBdvLJ.js";import{G as m,b as h,g,h as _,m as v,w as y,x as ee,y as b}from"./tree-Bi2FOU_h.js";import{r as x}from"./live-ingress-OuSlQ6q7.js";import{n as S,t as C}from"./types-s-3wFTyD.js";import{n as w}from"./stub-DPcZtI0s.js";import{I as T,M as te,k as ne,r as re}from"./workspace-BiCkglEt.js";import{Y as ie,g as ae}from"./index-CQx3WisY.js";var E=class extends Error{line;column;constructor(e,t,n){super(e),this.line=t,this.column=n}},oe=class{text;of;i=0;line=1;column=1;constructor(e,t=`profile`){this.text=e,this.of=t}get done(){return this.i>=this.text.length}pos(){return{line:this.line,column:this.column}}fail(e){throw new E(e,this.line,this.column)}peek(e=0){return this.text[this.i+e]??``}bump(){let e=this.text[this.i]??``;return this.i+=1,e===`
|
|
3
3
|
`?(this.line+=1,this.column=1):this.column+=1,e}skip(){for(;;){let e=this.peek();if(e===` `||e===` `||e===`
|
|
4
4
|
`||e===`\r`||e===``)this.bump();else if(e===`/`&&this.peek(1)===`/`)for(;!this.done&&this.peek()!==`
|
|
5
5
|
`;)this.bump();else if(e===`/`&&this.peek(1)===`*`){for(this.bump(),this.bump();!this.done&&(this.peek()!==`*`||this.peek(1)!==`/`);)this.bump();this.done&&this.fail(`This comment never closes.`),this.bump(),this.bump()}else return}}starts(e){return this.skip(),this.text.startsWith(e,this.i)}eat(e){if(!this.starts(e))return!1;for(let t=0;t<e.length;t+=1)this.bump();return!0}expect(e){this.eat(e)||this.fail(`Expected '${e}'.`)}ident(){this.skip();let e=this.peek();if(!/^[A-Za-z_$]/.test(e))return;let t=``;for(;/^[A-Za-z0-9_$]/.test(this.peek());)t+=this.bump();return t}expectIdent(){let e=this.ident();return e===void 0&&this.fail(`Expected a name.`),e}peekIdent(){return this.skip(),/^[A-Za-z_$][A-Za-z0-9_$]*/.exec(this.text.slice(this.i))?.[0]}rest(){return this.skip(),this.text.slice(this.i)}};function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){e.skip();let t=e.peek();t!==`'`&&t!==`"`&&e.fail(`Expected a string.`),e.bump();let n=``;for(;!e.done&&e.peek()!==t;){let t=e.bump();if(t!==`\\`){n+=t;continue}let r=e.bump(),i={n:`
|
|
6
6
|
`,r:`\r`,t:` `,"\\":`\\`,"'":`'`,'"':`"`};if(r in i)n+=i[r];else if(r===`u`){let t=``;for(let n=0;n<4;n+=1)t+=e.bump();n+=String.fromCharCode(Number.parseInt(t,16))}else n+=r}return e.peek()!==t&&e.fail(`This string never closes.`),e.bump(),n}function se(e){e.skip();let t=e.pos(),n=``;for(e.peek()===`-`&&(n+=e.bump());/^[0-9.eE+-]/.test(e.peek())&&n.length<64;)n+=e.bump();let r=Number(n);if(!Number.isFinite(r))throw new E(`'${n}' is not a number.`,t.line,t.column);return r}function k(e,t,n,r){let i=0;for(;!e.done;){if(r()&&i===0)return;let a=e.peek();a===`'`||a===`"`?O(e):(a!==``&&t.includes(a)?i+=1:a!==``&&n.includes(a)&&--i,e.bump())}}function ce(e){k(e,`<([{`,`>)]}`,()=>(e.skip(),e.peek()===`;`||e.peek()===`
|
|
7
7
|
`))}function le(e){k(e,`{([`,`})]`,()=>e.peek()===`;`),e.peek()===`;`&&e.bump()}function ue(e,t,n){e.expect(`{`);let r={};for(;!e.eat(`}`);){e.eat(`...`)&&e.fail(`This file doesn't use spreads.`);let i=e.pos(),a;if(a=e.peek()===`'`||e.peek()===`"`?O(e):e.expectIdent(),a===`__proto__`)throw new E(`'__proto__' sets what an object inherits, not a setting.`,i.line,i.column);if(Object.hasOwn(r,a))throw new E(`'${a}' is set twice.`,i.line,i.column);let o=t?`${t}.${a}`:a;n.push({path:o,line:i.line,column:i.column}),e.expect(`:`),r[a]=I(e,o,n),e.eat(`,`),e.done&&e.fail(`This object never closes.`)}return r}function de(e,t,n){e.expect(`[`);let r=[],i=0;for(;!e.eat(`]`);){e.eat(`...`)&&e.fail(`This file doesn't use spreads.`),e.skip();let a=e.pos(),o=t?`${t}.${String(i)}`:String(i);n.push({path:o,line:a.line,column:a.column}),r.push(I(e,o,n)),i+=1,e.eat(`,`),e.done&&e.fail(`This array never closes.`)}return r}function fe(e,t,n){let[r]=t;return e!==`z.fromJSONSchema`&&n.fail(`The studio reads a schema as JSON Schema: z.fromJSONSchema({ ... }), not '${e}'.`),D(r)||n.fail(`z.fromJSONSchema() needs a schema.`),r}function A(e){return D(e)&&e.kind===`member`}function pe(e,t){return{kind:`member`,object:e,name:t}}function j(e){if(typeof e.object==`string`)return`${e.object}.${e.name}`;if(A(e.object)){let t=j(e.object);return t?`${t}.${e.name}`:void 0}}function M(e,t,n){let r=e[0];return D(r)||t.fail(n),r}function me(e,t,n){let r=M(e,t,`registerTool() needs the tool object.`),i=r.type,a=typeof i==`string`&&C.includes(i);if(i!==void 0&&!a){let e=n.findLast(e=>e.path===`type`)??t.pos();throw new E(S,e.line,e.column)}return{kind:`registerTool`,tool:r}}function he(e,t,n,r){if(n.of===`provider`){if(e!==`registerProvider`)return n.fail(`'${e}' isn't part of a provider's code.`);let[r,i={}]=t;return typeof r!=`string`&&n.fail(`registerProvider() needs the definition it registers from.`),(!D(i)||t.length>2)&&n.fail(`registerProvider() takes the definition and its settings.`),{kind:`provider`,definition:r,spec:i}}return e===`compileDetect`?M(t,n,`compileDetect() needs the detect object.`):e===`defineProfile`?M(t,n,`defineProfile() needs the profile object.`):e===`registerTool`?me(t,n,r):e===`registerStructured`?{kind:`registerStructured`,args:t}:e===`registerProfile`||e===`registerProvider`?{kind:e}:n.fail(`'${e}' isn't part of this file.`)}function ge(e,t,n){return(typeof t!=`string`||e.some(e=>typeof e!=`string`))&&n.fail(`.join() here joins lines of one string.`),e.join(t)}function _e(e,t,n){if(e.name===`join`&&Array.isArray(e.object))return ge(e.object,t[0],n);if(e.name===`resolve`&&e.object===`Promise`)return t[0];let r=j(e);return r?.startsWith(`z.`)?fe(r,t,n):n.fail(`This call isn't part of this file.`)}function ve(e,t,n,r){return typeof e==`string`?he(e,t,n,r):(A(e)||n.fail(`This call isn't part of this file.`),_e(e,t,n))}function ye(e){return/^(async\s*)?\(\s*\)\s*=>/.test(e.rest())}function be(e,t,n){return e.peekIdent()===`async`&&e.expectIdent(),e.expect(`(`),e.eat(`)`)||e.fail(`A handler here takes no arguments. It returns a fixed value.`),e.expect(`=>`),I(e,t,n)}var N=class{name;constructor(e){this.name=e}};function P(e){return e instanceof N?e.name:e}function F(e,t,n){return ye(e)?be(e,t,n):Se(xe(e,t,n),e,t,n)}function xe(e,t,n){e.skip();let r=e.peek();if(r===`'`||r===`"`)return O(e);if(r==="`"&&e.fail(`This file doesn't use template strings.`),r===`-`||/^[0-9]/.test(r))return se(e);if(r===`{`)return ue(e,t,n);if(r===`[`)return de(e,t,n);if(r===`(`){e.bump();let r=F(e,t,n);return e.expect(`)`),r}let i=e.ident();return i===`true`?!0:i===`false`?!1:i===`null`?null:(i===void 0&&e.fail(`Expected a value.`),new N(i))}function I(e,t,n){e.skip();let r=e.pos(),i=F(e,t,n);if(!(i instanceof N))return i;if(i.name!==`undefined`)throw new E(`'${i.name}' is set somewhere else. Write its value here.`,r.line,r.column)}function Se(e,t,n,r){let i=e;for(;;)if(t.eat(`.`)){let e=t.expectIdent();i=pe(P(i),e)}else if(t.eat(`(`)){let e=r.length,a=[];for(;!t.eat(`)`);)a.push(P(F(t,n,r))),t.eat(`,`),t.done&&t.fail(`This call never closes.`);i=ve(P(i),a,t,r.slice(e))}else return A(i)&&t.fail(`This file doesn't stop on a property.`),i}function Ce(e,t){e.expectIdent();let n=e.expectIdent();e.expect(`=`);let r=F(e,``,t.spans);(e.eat(`satisfies`)||e.eat(`as`))&&ce(e),e.eat(`;`),e.of===`provider`?e.fail(`A provider's code is its registerProvider() call and nothing else.`):n===`profile`?(D(r)||e.fail(`profile has to be the defineProfile() object.`),t.profile&&e.fail(`This file defines two profiles.`),t.profile=r):n===`questions`?(D(r)||e.fail(`questions has to be an object.`),t.questions=r):n===`images`&&(D(r)||e.fail(`images has to be an object.`),t.images=r)}function we(e,t){let n=F(e,``,t.spans);if(e.eat(`;`),D(n)){if(n.kind===`provider`&&typeof n.definition==`string`&&D(n.spec))t.provider&&e.fail(`This code registers two providers.`),t.provider={definition:n.definition,spec:n.spec};else if(n.kind===`registerTool`){let r=n.tool;D(r)||e.fail(`registerTool() needs the tool object.`),t.tools.push(r)}else if(n.kind===`registerStructured`){let[r,i]=Array.isArray(n.args)?n.args:[];(typeof r!=`string`||!D(i))&&e.fail(`registerStructured() needs an id and a spec.`),t.structured={id:r,spec:i}}}}function L(e,t=`profile`){let n=new oe(e,t),r={tools:[],spans:[]};for(n.skip();!n.done;n.skip())n.peekIdent()===`import`?(n.expectIdent(),le(n)):(n.peekIdent()===`export`&&n.expectIdent(),n.peekIdent()===`const`?Ce(n,r):we(n,r));return t===`provider`?r.provider||n.fail(`This code needs registerProvider().`):r.profile||n.fail(`This file needs defineProfile().`),r}function R(e,t=``){return typeof e==`string`?e:t}function z(e){return typeof e==`number`?e:null}function Te(e,t){if(e===void 0)return``;if(typeof e==`string`)return e;if(!Array.isArray(e))throw new E(t,1,1);return e.map(e=>{if(typeof e==`string`)return e;if(D(e)&&typeof e.private==`string`)return`{private: ${e.private}}`;throw new E(t,1,1)}).join(``)}function B(e){return e===void 0?``:JSON.stringify(e,null,2)}function Ee(e,t){return T(e)===T(t)}function V(e){return D(e)?JSON.stringify(e,null,2):JSON.stringify(e)}function H(e){return Array.isArray(e)?e.map(e=>{if(!D(e)||typeof e.name!=`string`)throw new E(`A pattern needs a name.`,1,1);return Array.isArray(e.words)?{name:e.name,kind:`words`,pattern:``,flags:``,words:e.words.filter(e=>typeof e==`string`)}:{name:e.name,kind:`pattern`,pattern:R(e.pattern),flags:R(e.flags),words:[]}}):[]}function U(e){return D(e)?e:void 0}function W(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function G(e){return Array.isArray(e)?W(e):void 0}function K(e){return R(e)||void 0}function q(e){return Array.isArray(e)?W(e).join(`
|
|
8
|
-
`)||void 0:K(e)}function J(e,t,n){return D(e)?t(e):n}function De(e,t,n){if(!D(n))return;if(Array.isArray(n.names)){e.innocentNames=W(n.names);return}if(!(t in e.allow))return;let r=e.allow[t];r.hosts=W(n.hosts),r.fromTools=n.fromTools!==!1}function Oe(e,t,n){let r=U(n.at)??{};e.detect[t]={...e.detect[t],...r};let i=e.sources[t];i&&(n.theorem===!1&&(i.theorem=!1),i.patterns=H(n.patterns),i.hint=R(n.hint)),De(e,t,n.allow)}function ke(e,t){let n=d(p,()=>`ignore`);return D(t.at)&&Object.assign(n,t.at),{key:e,label:R(t.label),at:n,patterns:H(t.patterns),hint:R(t.hint)}}function Ae(e){let t=b().guardrails;if(!D(e))return t;let n={detect:structuredClone(t.detect),sources:structuredClone(t.sources),allow:structuredClone(t.allow),innocentNames:[...t.innocentNames]},r=[],i=new Set(f);for(let[t,a]of Object.entries(U(e.detect)??{}))D(a)&&(i.has(t)?Oe(n,t,a):r.push(ke(t,a)));let a=U(e.quota),o=U(e.blockedReply),s=U(e.network),c=U(e.taint);return{...t,...n,own:r,quotaEnabled:a!==void 0,quotaPerDay:z(a?.perDay),blockedReplyOnBlock:R(o?.onBlock),blockedReplyMaxRetries:z(o?.maxRetries),allowPrivateNetworks:s?.allowPrivateNetworks===!0,allowedHosts:W(s?.allowedHosts),allowedSchemes:W(s?.allowedSchemes),taintAfterRemoteRead:R(c?.afterRemoteRead),taintRemoteDestination:R(c?.remoteDestination)}}var je={"continue.instruction":(e,t)=>{e.turnBehaviour.continueInstruction=t},"canary.bind_note":(e,t)=>{e.guardrails.canaryBindNote=t},"quota.exhausted":(e,t)=>{e.guardrails.quotaMessage=t},"repair.default_guidance":(e,t)=>{e.outputs.repairGuidance=t},"egress.default_repair_guidance":(e,t)=>{e.guardrails.egressRepairGuidance=t},"egress.refusal":(e,t)=>{e.guardrails.egressRefusal=t}};function Me(e,t){if(!D(t))return;let n={};for(let[r,i]of Object.entries(t)){if(typeof i!=`string`)continue;let t=je[r];t?t(e,i):v[r]||(n[r]=i)}e.labels=n}function Ne(e){if(D(e))return Object.fromEntries(_.map(({name:t})=>[t,z(e[t])]))}function Pe(e,t,n,r,i){let a=n??h({modelId:e});if(!D(t))return{...a,modelId:e};let o=D(t.efforts)?Object.entries(t.efforts).map(([e,t])=>({alias:e,level:t})):[],s=D(t.compaction)?t.compaction:void 0,c=R(s?.profile),l=z(t.timeoutMs);return{...a,modelId:e,protocol:R(t.protocol,a.protocol),provider:R(t.provider,a.provider),apiId:R(t.apiId),options:U(t.options)??{},timeoutMs:l,limits:Ne(t.limits),efforts:o,defaultEffort:R(t.defaultEffort),allowEffortSelect:t.allowEffortSelect===!0,summaries:typeof t.summaries==`boolean`?t.summaries:null,maxOutputTokens:z(t.maxOutputTokens),temperature:typeof t.temperature==`number`?t.temperature:null,builtInTools:Array.isArray(t.builtInTools)?t.builtInTools.filter(e=>typeof e==`string`):[],keySlot:R(t.keySlot),fallbackKeySlot:R(t.fallbackKeySlot),compactTiming:R(s?.timing),compactMaxTokens:z(s?.maxTokens),compactAt:typeof s?.compactAt==`number`?s.compactAt:void 0,compactKeep:z(s?.previousExchanges),compactMeter:R(s?.meter),compactWith:c?Fe(c,r,`models.${e}.compaction.profile`,i):``}}function Fe(e,t,n,r){return t?t(e)??Z(r,n,`'${e}' is not an agent here, so it can't write this model's summaries.`):``}function Ie(e,t){let n=t.output;if(e===`function`&&D(t.handler)&&D(n)&&!Ee(t.handler,w(n)))return B(t.handler)}function Le(e){let t=U(e.mapping)??{};return{endpoint:K(e.endpoint),method:K(e.method),headersJson:D(e.headers)?B(e.headers):void 0,pathParams:G(t.pathParams),queryParams:G(t.queryParams),bodyParam:K(t.bodyParam),serverUrl:K(e.serverUrl),mcpToolName:K(e.mcpToolName),maxResponseBytes:z(e.maxResponseBytes),sessionIdleMs:z(U(e.session)?.idleMs),sessionMax:z(U(e.session)?.max)}}function Re(e){let t=U(e.auth)??{};return{authType:R(t.type),authSlot:K(t.slot),authService:K(t.service),authHeaderName:K(t.headerName),authHeaderPrefix:typeof t.headerPrefix==`string`?t.headerPrefix:void 0,authQueryParam:K(t.queryParam),authUnauthenticated:R(t.onUnauthenticated),authScopes:G(t.scopes),authClientId:K(t.clientId),authRedirectUri:K(t.redirectUri)}}function ze(e,t,n){let r=t??ee(),i=R(e.type,r.toolType),a=U(e.labels)??{},o=R(e.profile),s=e.answeredBy===`page`;return{...r,key:t?.key??y(`tool`),toolName:R(e.name,r.toolName),toolType:i,description:R(e.description),category:R(e.category,`studio`),access:R(e.access,r.access),permission:R(e.permission,r.permission),loadTier:R(e.loadTier,r.loadTier),paths:G(e.paths)??[`*`],inputJson:e.input===void 0?r.inputJson:V(e.input),outputJson:e.output===void 0?r.outputJson:V(e.output),activity:q(a.activity),activityPast:q(a.activityPast),activityFailed:q(a.activityFailed),request:q(a.request),stubOutputJson:s?t?.stubOutputJson:Ie(i,e),answeredBy:s?`page`:void 0,...Le(e),agentKey:o?n?.(o):void 0,maxCallsPerTurn:z(e.maxCallsPerTurn),...Re(e)}}function Be(e,t){let n=new Map(t.map(e=>[e.id,e]));return Object.entries(e).map(([e,t])=>{let r=n.get(e),i=D(t)?t:{},a=R(i.type,`choice`),o=i.criteria,s=Array.isArray(o)?o.map((e,t)=>({key:r?.criteria[t]?.key??y(`criterion`),label:``,text:R(e)})):D(o)?Object.entries(o).map(([e,t],n)=>({key:r?.criteria[n]?.key??y(`criterion`),label:e,text:R(t)})):[];return{key:r?.key??y(`question`),id:e,type:a,instructions:R(i.instructions),criteria:s,...a===`box`&&R(i.image)?{image:R(i.image)}:{}}})}function Ve(e){if(!Array.isArray(e))return[];let t=[];for(let n of e)if(D(n)){if(typeof n.uri==`string`){let e=R(n.name);t.push({key:y(`reference`),uri:n.uri,...e?{name:e}:{}})}else typeof n.data==`string`&&t.push({key:y(`reference`),name:R(n.name),mimeType:R(n.mimeType),data:n.data})}return t}function He(e,t){return e?m.filter(n=>!n.optional||n.role===`branch`||!n.profileTypes.includes(e)?!1:n.profilePath in t).map(e=>e.id):b().included}function Ue(e,t,n,r){let i=[],a=new Set;for(let o of e){let e=ze(o,t.get(R(o.name)),n);if(e.toolName&&a.has(e.toolName)){let t=r.filter(e=>e.path===`name`)[i.length]??{line:1,column:1};throw new E(`'${e.toolName}' is registered twice.`,t.line,t.column)}e.toolName&&a.add(e.toolName),i.push(e)}return i}function We(e,t,n){if(t===void 0)return[];let r=n.findLast(e=>e.path===`tools.allow`)??{line:1,column:1};if(!Array.isArray(t))throw new E(`tools.allow has to be a list of tool names.`,r.line,r.column);let i=new Map(e.map(e=>[e.toolName,e])),a=[],o=new Set;for(let[e,s]of t.entries()){let t=n.find(t=>t.path===`tools.allow.${String(e)}`)??r;if(typeof s!=`string`||s.trim()===``)throw new E(`tools.allow names tools.`,t.line,t.column);if(o.has(s))throw new E(`'${s}' is listed twice in tools.allow.`,t.line,t.column);o.add(s);let c=i.get(s);if(!c)throw new E(`'${s}' is in tools.allow, and this file has no registerTool for it.`,t.line,t.column);a.push(c)}return a}function Ge(e,t,n){let r=U(t.identity)??{},i=r.systemByRole;return{...e,agentId:R(t.id),profileType:n,handle:R(r.handle),system:Te(r.system,`The system prompt has to be text.`),systemByRoleJson:D(i)||Array.isArray(i)?B(i):``}}function Ke(e){return{...D(e.providerContinuation)&&(e.providerContinuation.history===`provider`||e.providerContinuation.history===`stateless`)?{providerHistory:e.providerContinuation.history}:{},defaultModel:R(e.defaultModel),allowModelSelect:e.allowModelSelect===!0,maxSteps:z(e.maxSteps),key:R(e.key),fallbackKey:R(e.fallbackKey)}}function qe(e){return o.includes(e)}function Je(e){let t=U(e.context);return{text:e.text!==!1,attachmentsAccept:W(U(e.attachments)?.accept),voiceAccept:W(U(e.voice)?.accept),maxFiles:z(e.maxFiles),maxBytes:z(e.maxBytes),maxTurnBytes:z(e.maxTurnBytes),limitsByMimeJson:B(e.limitsByMime),slotsJson:B(e.slots),contextFrom:W(t?.from).filter(qe),contextMaxChars:z(t?.maxChars)}}function Ye(e){return Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,U(t)?.onFail===`fix`?`fix`:`drop`]))}function Xe(e,t){let n=t?.id??R(e?.structured),r=U(e?.streaming),i=U(e?.validation);return{mode:n?`structured`:`text`,schemaId:n,schemaJson:B(t?.spec.jsonSchema),streamMode:R(r?.mode),streamThoughts:r?.streamThoughts!==!1,validationEnabled:i!==void 0,maxRetries:z(i?.maxRetries),itemRules:Ye(U(i?.items)),repairGuidance:``}}function Ze(e){let t=U(e.resumption),n=Array.isArray(t?.allowContinue)?t.allowContinue:[...c],r=Array.isArray(t?.autoContinue)?t.autoContinue:[...a];return{resumeEnabled:n.length>0||r.length>0,allowContinue:n,autoContinue:r,maxContinues:z(t?.maxContinues),continueInstruction:``,allowSteering:e.allowSteering!==!1,atStepLimit:e.atStepLimit===`answer`?`answer`:`stop`}}function Qe(e){let t=b().observability,n=typeof e.writeTo==`string`&&e.writeTo?e.writeTo:t.destination;return{...t,writeTo:e.writeTo!==!1&&n,destination:n,sampleRate:typeof e.sampleRate==`number`?e.sampleRate:t.sampleRate,include:{...t.include,...U(e.include)},scrub:{...t.scrub,...U(e.scrub)},retainForDays:z(e.retainForDays),rotateAfterMiB:z(e.rotateAfterMiB),resourceJson:B(e.resource)}}function $e(e){return{aspectRatio:R(e.aspectRatio),resolution:R(e.resolution),mimeType:R(e.mimeType),quality:R(e.quality),background:R(e.background),n:z(e.n),seed:z(e.seed),outputCompression:z(e.outputCompression),includeText:e.includeText===!0,references:Ve(e.references)}}function et(e){return{voice:R(e.voice),style:R(e.style),speed:z(e.speed),format:R(e.format)}}function Y(e,t){let n=e[t];return typeof n==`boolean`?n:x(t)}function tt(e){let t=U(e.ingress)??{},n=U(e.vad)??{},r=U(e.contextCompression),i=U(r?.slidingWindow),a=U(e.transcription);return{ingressAudio:Y(t,`audio`),ingressVideo:Y(t,`video`),ingressText:Y(t,`text`),voice:R(e.voice),sessionResumption:e.sessionResumption===!0,greeting:R(e.greeting),resumedPrompt:R(U(e.resumed)?.prompt),resumedAfterMs:z(U(e.resumed)?.afterMs),contextCompression:r!==void 0,compressionTriggerTokens:z(r?.triggerTokens),compressionTargetTokens:z(i?.targetTokens),transcriptionInput:a?.input===!0,transcriptionOutput:a?.output===!0,vadActivityHandling:R(n.activityHandling),vadStartSensitivity:R(n.startSensitivity),vadEndSensitivity:R(n.endSensitivity),vadPrefixPaddingMs:z(n.prefixPaddingMs),vadSilenceDurationMs:z(n.silenceDurationMs)}}function nt(e,t,n){let r=z(U(t.profile?.inputs)?.maxStateBytes);return{contract:R(e.contract),maxStateBytes:r,questions:t.questions?Be(t.questions,n.questions):[],images:t.images?rt(t.images,n.images):[]}}function rt(e,t){let n=new Map(t.map(e=>[e.name,e]));return Object.entries(e).map(([e,t])=>{let r=e.replace(/^<|>$/g,``),i=D(t)?t:{};return{key:n.get(r)?.key??y(`image`),name:r,mimeType:R(i.mimeType),data:R(i.data)}})}function it(e){let t=R(e.type);if(t&&!g.includes(t))throw new E(`'${t}' is not a profile type.`,1,1);return t}var at=[`turnBehaviour.atStepLimit`,`outputs.validation.items.*.onFail`];function ot(e,t){for(let n of at){let r=l(n)?.options??[];for(let[i,a]of X(e,n.split(`.`),[]))a!==void 0&&!r.includes(a)&&Z(t,i,`${JSON.stringify(a)} is not one of ${r.map(e=>`'${e}'`).join(`, `)}.`)}}function X(e,t,n){let[r,...i]=t;return r===void 0?[[n.join(`.`),e]]:D(e)?(r===`*`?Object.keys(e):[r]).flatMap(t=>X(e[t],i,[...n,t])):[]}function st(e,t,n){let r=e.profile??{},i=it(r);ot(r,e.spans);let a=new Map(t.modelBindings.map(e=>[e.modelId,e])),o=new Map(t.toolSpecs.map(e=>[e.toolName,e])),s=U(r.tools)??{},c=U(r.inputs),l=U(r.outputs),u={...t,identity:Ge(t.identity,r,i),included:He(i,r),models:Ke(r),modelBindings:Object.entries(U(r.models)??{}).map(([t,r])=>Pe(t,r,a.get(t),n,e.spans)),tools:{t2Loader:R(s.t2Loader),parallel:s.parallel===!0},toolSpecs:[],inputs:c&&i!==`decision`?Je(c):t.inputs,outputs:l||e.structured?Xe(l,e.structured):t.outputs,turnBehaviour:J(r.turnBehaviour,Ze,t.turnBehaviour),guardrails:J(r.guardrails,Ae,t.guardrails),observability:J(r.observability,Qe,t.observability),image:J(r.image,$e,t.image),speech:J(r.speech,et,t.speech),live:J(r.live,tt,t.live),decision:J(r.decision,n=>nt(n,e,t.decision),t.decision),labels:{}},d=Ue(e.tools,o,n,e.spans),f=We(d,s.allow,e.spans);u.toolSpecs=f;let p=new Set(f.map(e=>e.toolName));return u.tools.t2Loader&&!p.has(u.tools.t2Loader)&&(u.tools={...u.tools,t2Loader:``}),Me(u,r.labels),{draft:u,registered:d}}function ct(e,t,n){try{let r=L(e),{draft:i,registered:a}=st(r,t,n);return{ok:!0,draft:i,spans:r.spans,registered:a}}catch(e){if(e instanceof E)return{ok:!1,errors:[{message:e.message,line:e.line,column:e.column}]};throw e}}function Z(e,t,n){let r=e.findLast(e=>e.path===t)??{line:1,column:1};throw new E(n,r.line,r.column)}var lt=new Set([`id`,`connection`,`keySlot`,`fallbackKeySlot`]);function ut(e,t,n){let{spec:r}=e;for(let e of Object.keys(r))lt.has(e)||Z(n,e,`'${e}' isn't a provider setting the studio holds.`);r.id!==t.id&&Z(n,`id`,`The id stays '${t.id}': models and code name the provider by it.`);let a=i(e.definition);if(!a){let t=u().flatMap(e=>s(e)??[]).join(`, `);Z(n,``,`'${e.definition}' isn't one of the kernel's providers: ${t}.`)}let o=r.connection===void 0?{}:dt(r.connection,n),c=Object.keys(o).length===0&&t.connection===void 0,l={id:t.id,definition:a,...c?{}:{connection:o}};for(let e of[`keySlot`,`fallbackKeySlot`]){let t=r[e];t!==void 0&&(typeof t!=`string`&&Z(n,e,`${e} names a key slot.`),l[e]=t)}return l}function dt(e,t){let n=`connection holds text settings here.`,r={};D(e)||Z(t,`connection`,n);for(let[i,a]of Object.entries(e))typeof a!=`string`&&Z(t,`connection`,n),r[i]=a;return r}function ft(e,t){try{let n=L(e,`provider`);if(!n.provider)throw new E(`This code needs registerProvider().`,1,1);return{ok:!0,provider:ut(n.provider,t,n.spans),spans:n.spans}}catch(e){if(e instanceof E)return{ok:!1,errors:[{message:e.message,line:e.line,column:e.column}]};throw e}}var Q=e(n(),1),$=t(),pt=300,mt=2e3;function ht({editor:e,monaco:t,spans:n,errors:r},i){let a=e?.getModel();t&&a&&t.editor.setModelMarkers(a,`studio`,[...r.map(e=>_t(t,e.line,e.column,e.message)),...vt(t,n,i)])}function gt({text:e,hold:t,isReadOnly:n=!1,issues:i,onApply:a}){let o=(0,Q.useRef)(null),s=(0,Q.useRef)(a),c=(0,Q.useRef)(e),l=(0,Q.useRef)(n);l.current=n;let u=(0,Q.useRef)(i),d=(0,Q.useRef)({spans:[],errors:[],setting:!1,dirty:!1});return s.current=a,c.current=e,u.current=i,(0,Q.useEffect)(()=>{let e=o.current;if(!e)return;let t={disposed:!1},n,i,a=0,f,p=!1,m=!1,h=()=>{a+=1,i&&clearTimeout(i),i=void 0,f?.stop(),f=void 0,p=!1,m=!1},g=t=>e.contains(t)?!0:t instanceof Element&&!!t.closest(`.suggest-widget, .parameter-hints-widget, .monaco-hover, .monaco-menu-container, .context-view`),_=()=>!!document.querySelector(`.suggest-widget.visible, .parameter-hints-widget.visible`),v,y=()=>{ht(d.current,u.current)};return(async()=>{let o=await r(()=>import(`./studio-monaco-xfyfezQS.js`),__vite__mapDeps([0,1,2,3,4]));await r(()=>import(`./register-CDgivxvX.js`),__vite__mapDeps([5,2,1,3]));let u=(await r(async()=>{let{default:e}=await import(`./editor.worker-6GY8RhDc.js`);return{default:e}},[])).default;if(self.MonacoEnvironment={getWorker(){return new u}},t.disposed||!e.isConnected)return;let ee=document.documentElement.dataset.theme===`dark`||globalThis.matchMedia(`(prefers-color-scheme: dark)`).matches,b=o.Uri.parse(`file:///agent.ts`);o.editor.getModel(b)?.dispose();let x=o.editor.createModel(c.current,`typescript`,b),S=o.editor.create(e,{model:x,readOnly:l.current,language:`typescript`,theme:ee?`vs-dark`:`vs`,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,wrappingIndent:`indent`,scrollBeyondLastLine:!1,automaticLayout:!0,fixedOverflowWidgets:!0,tabSize:2,padding:{top:12},quickSuggestions:{other:!0,comments:!1,strings:!0},suggestOnTriggerCharacters:!0,acceptSuggestionOnEnter:`on`,tabCompletion:`on`,wordBasedSuggestions:`currentDocument`,parameterHints:{enabled:!0},suggest:{preview:!0,showIcons:!0}});d.current.editor=S,d.current.monaco=o;let C=()=>{i&&clearTimeout(i),i=setTimeout(()=>{t.disposed||(_()?C():h())},mt)},w=()=>{if(f){m&&C();return}if(p)return;let e=a,n=()=>t.disposed||e!==a;p=!0,r(async()=>{let{openTypeChecker:e}=await import(`./studio-type-checker-CHFs7A7H.js`);return{openTypeChecker:e}},__vite__mapDeps([6,2])).then(({openTypeChecker:r})=>{if(n())return;let i=r(o,S,()=>{t.disposed||e!==a||(m=!0,C())});n()?i.stop():f=i}).catch(()=>{}).finally(()=>{e===a&&(p=!1)})};S.onKeyDown(e=>{let t=e.browserEvent;t.metaKey||t.ctrlKey||t.altKey||m&&C()});let T=e=>{let t=e.target;t instanceof Node&&!g(t)&&h()};document.addEventListener(`pointerdown`,T,!0),v=()=>{document.removeEventListener(`pointerdown`,T,!0)},S.onDidBlurEditorText(()=>{queueMicrotask(()=>{if(t.disposed||S.hasTextFocus())return;let e=document.activeElement;e&&g(e)||h()})}),S.onDidChangeModelContent(()=>{if(d.current.setting)return;w();let e=S.getValue();d.current.dirty=e!==c.current,n&&clearTimeout(n),n=setTimeout(()=>{let t=s.current(e);d.current.spans=t.spans,d.current.errors=t.errors,y()},pt)}),y()})(),()=>{t.disposed=!0,v?.(),h(),n&&clearTimeout(n);let e=d.current.editor?.getModel();d.current.editor?.dispose(),e?.dispose(),d.current.editor=void 0}},[]),(0,Q.useEffect)(()=>{let{editor:n}=d.current;n&&!t&&(d.current.dirty&&n.getValue()!==e||(n.getValue()===e||(d.current.setting=!0,n.setValue(e),d.current.setting=!1),d.current.dirty=!1))},[e,t]),(0,Q.useEffect)(()=>{d.current.editor?.updateOptions({readOnly:n})},[n]),(0,Q.useEffect)(()=>{ht(d.current,i)},[i]),(0,$.jsx)(`div`,{ref:o,className:`studio-fill`})}function _t(e,t,n,r){return{startLineNumber:t,startColumn:n,endLineNumber:t,endColumn:n+1,message:r,severity:e.MarkerSeverity.Error}}function vt(e,t,n){return n.flatMap(n=>{let r=n.field?`${n.nodeId}.${n.field}`:n.nodeId,i=t.find(e=>e.path===r)??(n.field?t.find(e=>e.path===n.field):void 0);return i?[_t(e,i.line,i.column,n.message)]:[]})}function yt({source:e,blocked:t,issues:n,state:r}){let i=(0,Q.useRef)(e);e&&(i.current=e);let a=(0,Q.useCallback)(e=>{let t=re(r.workspace,r.focus);if(!t)return{errors:[{message:`No agent is open.`,line:1,column:1}],spans:[]};let n=ct(e,{...t,toolSpecs:r.workspace.toolSpecs},e=>r.workspace.agents.find(t=>t.identity.agentId.trim()===e)?.key);return n.ok?(r.update(e=>ne(e,r.focus,n.draft,n.registered)),{errors:[],spans:n.spans}):{errors:n.errors,spans:[]}},[r]);return i.current?(0,$.jsx)(`div`,{className:`studio-fill`,children:(0,$.jsx)(gt,{text:e??i.current,hold:e==null,issues:n,onApply:a})}):(0,$.jsx)(ie,{title:`No code yet`,description:`${t??``} to generate the TypeScript.`})}function bt({provider:e,issues:t,state:n,isEditable:r}){let i=(0,Q.useCallback)(t=>{let r=n.workspace.providers.find(t=>t.id===e.id);if(!r)return{errors:[{message:`No provider is open.`,line:1,column:1}],spans:[]};let i=ft(t,r);return i.ok?(n.update(e=>te(e,i.provider)),{errors:[],spans:i.spans}):{errors:i.errors,spans:[]}},[n,e.id]);return(0,$.jsx)(`div`,{className:`studio-fill`,children:(0,$.jsx)(gt,{text:ae(e),hold:!1,isReadOnly:!r||s(e.definition)===void 0,issues:t,onApply:i},e.id)})}export{yt as CodeBody,bt as ProviderCode};
|
|
8
|
+
`)||void 0:K(e)}function J(e,t,n){return D(e)?t(e):n}function De(e,t,n){if(!D(n))return;if(Array.isArray(n.names)){e.innocentNames=W(n.names);return}if(!(t in e.allow))return;let r=e.allow[t];r.hosts=W(n.hosts),r.fromTools=n.fromTools!==!1}function Oe(e,t,n){let r=U(n.at)??{};e.detect[t]={...e.detect[t],...r};let i=e.sources[t];i&&(n.theorem===!1&&(i.theorem=!1),i.patterns=H(n.patterns),i.hint=R(n.hint)),De(e,t,n.allow)}function ke(e,t){let n=d(f,()=>`ignore`);return D(t.at)&&Object.assign(n,t.at),{key:e,label:R(t.label),at:n,patterns:H(t.patterns),hint:R(t.hint)}}function Ae(e){let t=b().guardrails;if(!D(e))return t;let n={detect:structuredClone(t.detect),sources:structuredClone(t.sources),allow:structuredClone(t.allow),innocentNames:[...t.innocentNames]},r=[],i=new Set(p);for(let[t,a]of Object.entries(U(e.detect)??{}))D(a)&&(i.has(t)?Oe(n,t,a):r.push(ke(t,a)));let a=U(e.quota),o=U(e.blockedReply),s=U(e.network),c=U(e.taint);return{...t,...n,own:r,quotaEnabled:a!==void 0,quotaPerDay:z(a?.perDay),blockedReplyOnBlock:R(o?.onBlock),blockedReplyMaxRetries:z(o?.maxRetries),allowPrivateNetworks:s?.allowPrivateNetworks===!0,allowedHosts:W(s?.allowedHosts),allowedSchemes:W(s?.allowedSchemes),taintAfterRemoteRead:R(c?.afterRemoteRead),taintRemoteDestination:R(c?.remoteDestination)}}var je={"continue.instruction":(e,t)=>{e.turnBehaviour.continueInstruction=t},"canary.bind_note":(e,t)=>{e.guardrails.canaryBindNote=t},"quota.exhausted":(e,t)=>{e.guardrails.quotaMessage=t},"repair.default_guidance":(e,t)=>{e.outputs.repairGuidance=t},"egress.default_repair_guidance":(e,t)=>{e.guardrails.egressRepairGuidance=t},"egress.refusal":(e,t)=>{e.guardrails.egressRefusal=t}};function Me(e,t){if(!D(t))return;let n={};for(let[r,i]of Object.entries(t)){if(typeof i!=`string`)continue;let t=je[r];t?t(e,i):v[r]||(n[r]=i)}e.labels=n}function Ne(e){if(D(e))return Object.fromEntries(_.map(({name:t})=>[t,z(e[t])]))}function Pe(e,t,n,r,i){let a=n??h({modelId:e});if(!D(t))return{...a,modelId:e};let o=D(t.efforts)?Object.entries(t.efforts).map(([e,t])=>({alias:e,level:t})):[],s=D(t.compaction)?t.compaction:void 0,c=R(s?.profile),l=z(t.timeoutMs);return{...a,modelId:e,protocol:R(t.protocol,a.protocol),provider:R(t.provider,a.provider),apiId:R(t.apiId),options:U(t.options)??{},timeoutMs:l,limits:Ne(t.limits),efforts:o,defaultEffort:R(t.defaultEffort),allowEffortSelect:t.allowEffortSelect===!0,summaries:typeof t.summaries==`boolean`?t.summaries:null,maxOutputTokens:z(t.maxOutputTokens),temperature:typeof t.temperature==`number`?t.temperature:null,builtInTools:Array.isArray(t.builtInTools)?t.builtInTools.filter(e=>typeof e==`string`):[],keySlot:R(t.keySlot),fallbackKeySlot:R(t.fallbackKeySlot),compactTiming:R(s?.timing),compactMaxTokens:z(s?.maxTokens),compactAt:typeof s?.compactAt==`number`?s.compactAt:void 0,compactKeep:z(s?.previousExchanges),compactMeter:R(s?.meter),compactWith:c?Fe(c,r,`models.${e}.compaction.profile`,i):``}}function Fe(e,t,n,r){return t?t(e)??Z(r,n,`'${e}' is not an agent here, so it can't write this model's summaries.`):``}function Ie(e,t){let n=t.output;if(e===`function`&&D(t.handler)&&D(n)&&!Ee(t.handler,w(n)))return B(t.handler)}function Le(e){let t=U(e.mapping)??{};return{endpoint:K(e.endpoint),method:K(e.method),headersJson:D(e.headers)?B(e.headers):void 0,pathParams:G(t.pathParams),queryParams:G(t.queryParams),bodyParam:K(t.bodyParam),serverUrl:K(e.serverUrl),mcpToolName:K(e.mcpToolName),maxResponseBytes:z(e.maxResponseBytes),sessionIdleMs:z(U(e.session)?.idleMs),sessionMax:z(U(e.session)?.max)}}function Re(e){let t=U(e.auth)??{};return{authType:R(t.type),authSlot:K(t.slot),authService:K(t.service),authHeaderName:K(t.headerName),authHeaderPrefix:typeof t.headerPrefix==`string`?t.headerPrefix:void 0,authQueryParam:K(t.queryParam),authUnauthenticated:R(t.onUnauthenticated),authScopes:G(t.scopes),authClientId:K(t.clientId),authRedirectUri:K(t.redirectUri)}}function ze(e,t,n){let r=t??ee(),i=R(e.type,r.toolType),a=U(e.labels)??{},o=R(e.profile),s=e.answeredBy===`page`;return{...r,key:t?.key??y(`tool`),toolName:R(e.name,r.toolName),toolType:i,description:R(e.description),category:R(e.category,`studio`),access:R(e.access,r.access),permission:R(e.permission,r.permission),loadTier:R(e.loadTier,r.loadTier),paths:G(e.paths)??[`*`],inputJson:e.input===void 0?r.inputJson:V(e.input),outputJson:e.output===void 0?r.outputJson:V(e.output),activity:q(a.activity),activityPast:q(a.activityPast),activityFailed:q(a.activityFailed),request:q(a.request),stubOutputJson:s?t?.stubOutputJson:Ie(i,e),answeredBy:s?`page`:void 0,...Le(e),agentKey:o?n?.(o):void 0,maxCallsPerTurn:z(e.maxCallsPerTurn),...Re(e)}}function Be(e,t){let n=new Map(t.map(e=>[e.id,e]));return Object.entries(e).map(([e,t])=>{let r=n.get(e),i=D(t)?t:{},a=R(i.type,`choice`),o=i.criteria,s=Array.isArray(o)?o.map((e,t)=>({key:r?.criteria[t]?.key??y(`criterion`),label:``,text:R(e)})):D(o)?Object.entries(o).map(([e,t],n)=>({key:r?.criteria[n]?.key??y(`criterion`),label:e,text:R(t)})):[];return{key:r?.key??y(`question`),id:e,type:a,instructions:R(i.instructions),criteria:s,...a===`box`&&R(i.image)?{image:R(i.image)}:{}}})}function Ve(e){if(!Array.isArray(e))return[];let t=[];for(let n of e)if(D(n)){if(typeof n.uri==`string`){let e=R(n.name);t.push({key:y(`reference`),uri:n.uri,...e?{name:e}:{}})}else typeof n.data==`string`&&t.push({key:y(`reference`),name:R(n.name),mimeType:R(n.mimeType),data:n.data})}return t}function He(e,t){return e?m.filter(n=>!n.optional||n.role===`branch`||!n.profileTypes.includes(e)?!1:n.profilePath in t).map(e=>e.id):b().included}function Ue(e,t,n,r){let i=[],a=new Set;for(let o of e){let e=ze(o,t.get(R(o.name)),n);if(e.toolName&&a.has(e.toolName)){let t=r.filter(e=>e.path===`name`)[i.length]??{line:1,column:1};throw new E(`'${e.toolName}' is registered twice.`,t.line,t.column)}e.toolName&&a.add(e.toolName),i.push(e)}return i}function We(e,t,n){if(t===void 0)return[];let r=n.findLast(e=>e.path===`tools.allow`)??{line:1,column:1};if(!Array.isArray(t))throw new E(`tools.allow has to be a list of tool names.`,r.line,r.column);let i=new Map(e.map(e=>[e.toolName,e])),a=[],o=new Set;for(let[e,s]of t.entries()){let t=n.find(t=>t.path===`tools.allow.${String(e)}`)??r;if(typeof s!=`string`||s.trim()===``)throw new E(`tools.allow names tools.`,t.line,t.column);if(o.has(s))throw new E(`'${s}' is listed twice in tools.allow.`,t.line,t.column);o.add(s);let c=i.get(s);if(!c)throw new E(`'${s}' is in tools.allow, and this file has no registerTool for it.`,t.line,t.column);a.push(c)}return a}function Ge(e,t,n){let r=U(t.identity)??{},i=r.systemByRole;return{...e,agentId:R(t.id),profileType:n,handle:R(r.handle),system:Te(r.system,`The system prompt has to be text.`),systemByRoleJson:D(i)||Array.isArray(i)?B(i):``}}function Ke(e){return{...D(e.providerContinuation)&&(e.providerContinuation.history===`provider`||e.providerContinuation.history===`stateless`)?{providerHistory:e.providerContinuation.history}:{},defaultModel:R(e.defaultModel),allowModelSelect:e.allowModelSelect===!0,maxSteps:z(e.maxSteps),key:R(e.key),fallbackKey:R(e.fallbackKey)}}function qe(e){return c.includes(e)}function Je(e){let t=U(e.context);return{text:e.text!==!1,attachmentsAccept:W(U(e.attachments)?.accept),voiceAccept:W(U(e.voice)?.accept),maxFiles:z(e.maxFiles),maxBytes:z(e.maxBytes),maxTurnBytes:z(e.maxTurnBytes),limitsByMimeJson:B(e.limitsByMime),slotsJson:B(e.slots),contextFrom:W(t?.from).filter(qe),contextMaxChars:z(t?.maxChars)}}function Ye(e){return Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,U(t)?.onFail===`fix`?`fix`:`drop`]))}function Xe(e,t){let n=t?.id??R(e?.structured),r=U(e?.streaming),i=U(e?.validation);return{mode:n?`structured`:`text`,schemaId:n,schemaJson:B(t?.spec.jsonSchema),streamMode:R(r?.mode),streamThoughts:r?.streamThoughts!==!1,validationEnabled:i!==void 0,maxRetries:z(i?.maxRetries),itemRules:Ye(U(i?.items)),repairGuidance:``}}function Ze(e){let t=U(e.resumption),n=Array.isArray(t?.allowContinue)?t.allowContinue:[...s],r=Array.isArray(t?.autoContinue)?t.autoContinue:[...a];return{resumeEnabled:n.length>0||r.length>0,allowContinue:n,autoContinue:r,maxContinues:z(t?.maxContinues),continueInstruction:``,allowSteering:e.allowSteering!==!1,atStepLimit:e.atStepLimit===`answer`?`answer`:`stop`}}function Qe(e){let t=b().observability,n=typeof e.writeTo==`string`&&e.writeTo?e.writeTo:t.destination;return{...t,writeTo:e.writeTo!==!1&&n,destination:n,sampleRate:typeof e.sampleRate==`number`?e.sampleRate:t.sampleRate,include:{...t.include,...U(e.include)},scrub:{...t.scrub,...U(e.scrub)},retainForDays:z(e.retainForDays),rotateAfterMiB:z(e.rotateAfterMiB),resourceJson:B(e.resource)}}function $e(e){return{aspectRatio:R(e.aspectRatio),resolution:R(e.resolution),mimeType:R(e.mimeType),quality:R(e.quality),background:R(e.background),n:z(e.n),seed:z(e.seed),outputCompression:z(e.outputCompression),includeText:e.includeText===!0,references:Ve(e.references)}}function et(e){return{voice:R(e.voice),style:R(e.style),speed:z(e.speed),format:R(e.format)}}function Y(e,t){let n=e[t];return typeof n==`boolean`?n:x(t)}function tt(e){let t=U(e.ingress)??{},n=U(e.vad)??{},r=U(e.contextCompression),i=U(r?.slidingWindow),a=U(e.transcription);return{ingressAudio:Y(t,`audio`),ingressVideo:Y(t,`video`),ingressText:Y(t,`text`),voice:R(e.voice),sessionResumption:e.sessionResumption===!0,greeting:R(e.greeting),resumedPrompt:R(U(e.resumed)?.prompt),resumedAfterMs:z(U(e.resumed)?.afterMs),contextCompression:r!==void 0,compressionTriggerTokens:z(r?.triggerTokens),compressionTargetTokens:z(i?.targetTokens),transcriptionInput:a?.input===!0,transcriptionOutput:a?.output===!0,vadActivityHandling:R(n.activityHandling),vadStartSensitivity:R(n.startSensitivity),vadEndSensitivity:R(n.endSensitivity),vadPrefixPaddingMs:z(n.prefixPaddingMs),vadSilenceDurationMs:z(n.silenceDurationMs)}}function nt(e,t,n){let r=z(U(t.profile?.inputs)?.maxStateBytes);return{contract:R(e.contract),maxStateBytes:r,questions:t.questions?Be(t.questions,n.questions):[],images:t.images?rt(t.images,n.images):[]}}function rt(e,t){let n=new Map(t.map(e=>[e.name,e]));return Object.entries(e).map(([e,t])=>{let r=e.replace(/^<|>$/g,``),i=D(t)?t:{};return{key:n.get(r)?.key??y(`image`),name:r,mimeType:R(i.mimeType),data:R(i.data)}})}function it(e){let t=R(e.type);if(t&&!g.includes(t))throw new E(`'${t}' is not a profile type.`,1,1);return t}var at=[`turnBehaviour.atStepLimit`,`outputs.validation.items.*.onFail`];function ot(e,t){for(let n of at){let r=u(n)?.options??[];for(let[i,a]of X(e,n.split(`.`),[]))a!==void 0&&!r.includes(a)&&Z(t,i,`${JSON.stringify(a)} is not one of ${r.map(e=>`'${e}'`).join(`, `)}.`)}}function X(e,t,n){let[r,...i]=t;return r===void 0?[[n.join(`.`),e]]:D(e)?(r===`*`?Object.keys(e):[r]).flatMap(t=>X(e[t],i,[...n,t])):[]}function st(e,t,n){let r=e.profile??{},i=it(r);ot(r,e.spans);let a=new Map(t.modelBindings.map(e=>[e.modelId,e])),o=new Map(t.toolSpecs.map(e=>[e.toolName,e])),s=U(r.tools)??{},c=U(r.inputs),l=U(r.outputs),u={...t,identity:Ge(t.identity,r,i),included:He(i,r),models:Ke(r),modelBindings:Object.entries(U(r.models)??{}).map(([t,r])=>Pe(t,r,a.get(t),n,e.spans)),tools:{t2Loader:R(s.t2Loader),parallel:s.parallel===!0},toolSpecs:[],inputs:c&&i!==`decision`?Je(c):t.inputs,outputs:l||e.structured?Xe(l,e.structured):t.outputs,turnBehaviour:J(r.turnBehaviour,Ze,t.turnBehaviour),guardrails:J(r.guardrails,Ae,t.guardrails),observability:J(r.observability,Qe,t.observability),image:J(r.image,$e,t.image),speech:J(r.speech,et,t.speech),live:J(r.live,tt,t.live),decision:J(r.decision,n=>nt(n,e,t.decision),t.decision),labels:{}},d=Ue(e.tools,o,n,e.spans),f=We(d,s.allow,e.spans);u.toolSpecs=f;let p=new Set(f.map(e=>e.toolName));return u.tools.t2Loader&&!p.has(u.tools.t2Loader)&&(u.tools={...u.tools,t2Loader:``}),Me(u,r.labels),{draft:u,registered:d}}function ct(e,t,n){try{let r=L(e),{draft:i,registered:a}=st(r,t,n);return{ok:!0,draft:i,spans:r.spans,registered:a}}catch(e){if(e instanceof E)return{ok:!1,errors:[{message:e.message,line:e.line,column:e.column}]};throw e}}function Z(e,t,n){let r=e.findLast(e=>e.path===t)??{line:1,column:1};throw new E(n,r.line,r.column)}var lt=new Set([`id`,`connection`,`keySlot`,`fallbackKeySlot`]);function ut(e,t,n){let{spec:r}=e;for(let e of Object.keys(r))lt.has(e)||Z(n,e,`'${e}' isn't a provider setting the studio holds.`);r.id!==t.id&&Z(n,`id`,`The id stays '${t.id}': models and code name the provider by it.`);let a=i(e.definition);if(!a){let t=l().flatMap(e=>o(e)??[]).join(`, `);Z(n,``,`'${e.definition}' isn't one of the kernel's providers: ${t}.`)}let s=r.connection===void 0?{}:dt(r.connection,n),c=Object.keys(s).length===0&&t.connection===void 0,u={id:t.id,definition:a,...c?{}:{connection:s}};for(let e of[`keySlot`,`fallbackKeySlot`]){let t=r[e];t!==void 0&&(typeof t!=`string`&&Z(n,e,`${e} names a key slot.`),u[e]=t)}return u}function dt(e,t){let n=`connection holds text settings here.`,r={};D(e)||Z(t,`connection`,n);for(let[i,a]of Object.entries(e))typeof a!=`string`&&Z(t,`connection`,n),r[i]=a;return r}function ft(e,t){try{let n=L(e,`provider`);if(!n.provider)throw new E(`This code needs registerProvider().`,1,1);return{ok:!0,provider:ut(n.provider,t,n.spans),spans:n.spans}}catch(e){if(e instanceof E)return{ok:!1,errors:[{message:e.message,line:e.line,column:e.column}]};throw e}}var Q=e(n(),1),$=t(),pt=300,mt=2e3;function ht({editor:e,monaco:t,spans:n,errors:r},i){let a=e?.getModel();t&&a&&t.editor.setModelMarkers(a,`studio`,[...r.map(e=>_t(t,e.line,e.column,e.message)),...vt(t,n,i)])}function gt({text:e,hold:t,isReadOnly:n=!1,issues:i,onApply:a}){let o=(0,Q.useRef)(null),s=(0,Q.useRef)(a),c=(0,Q.useRef)(e),l=(0,Q.useRef)(n);l.current=n;let u=(0,Q.useRef)(i),d=(0,Q.useRef)({spans:[],errors:[],setting:!1,dirty:!1});return s.current=a,c.current=e,u.current=i,(0,Q.useEffect)(()=>{let e=o.current;if(!e)return;let t={disposed:!1},n,i,a=0,f,p=!1,m=!1,h=()=>{a+=1,i&&clearTimeout(i),i=void 0,f?.stop(),f=void 0,p=!1,m=!1},g=t=>e.contains(t)?!0:t instanceof Element&&!!t.closest(`.suggest-widget, .parameter-hints-widget, .monaco-hover, .monaco-menu-container, .context-view`),_=()=>!!document.querySelector(`.suggest-widget.visible, .parameter-hints-widget.visible`),v,y=()=>{ht(d.current,u.current)};return(async()=>{let o=await r(()=>import(`./studio-monaco-xfyfezQS.js`),__vite__mapDeps([0,1,2,3,4]));await r(()=>import(`./register-CDgivxvX.js`),__vite__mapDeps([5,2,1,3]));let u=(await r(async()=>{let{default:e}=await import(`./editor.worker-6GY8RhDc.js`);return{default:e}},[])).default;if(self.MonacoEnvironment={getWorker(){return new u}},t.disposed||!e.isConnected)return;let ee=document.documentElement.dataset.theme===`dark`||globalThis.matchMedia(`(prefers-color-scheme: dark)`).matches,b=o.Uri.parse(`file:///agent.ts`);o.editor.getModel(b)?.dispose();let x=o.editor.createModel(c.current,`typescript`,b),S=o.editor.create(e,{model:x,readOnly:l.current,language:`typescript`,theme:ee?`vs-dark`:`vs`,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,wrappingIndent:`indent`,scrollBeyondLastLine:!1,automaticLayout:!0,fixedOverflowWidgets:!0,tabSize:2,padding:{top:12},quickSuggestions:{other:!0,comments:!1,strings:!0},suggestOnTriggerCharacters:!0,acceptSuggestionOnEnter:`on`,tabCompletion:`on`,wordBasedSuggestions:`currentDocument`,parameterHints:{enabled:!0},suggest:{preview:!0,showIcons:!0}});d.current.editor=S,d.current.monaco=o;let C=()=>{i&&clearTimeout(i),i=setTimeout(()=>{t.disposed||(_()?C():h())},mt)},w=()=>{if(f){m&&C();return}if(p)return;let e=a,n=()=>t.disposed||e!==a;p=!0,r(async()=>{let{openTypeChecker:e}=await import(`./studio-type-checker-B5DVxAZ0.js`);return{openTypeChecker:e}},__vite__mapDeps([6,2])).then(({openTypeChecker:r})=>{if(n())return;let i=r(o,S,()=>{t.disposed||e!==a||(m=!0,C())});n()?i.stop():f=i}).catch(()=>{}).finally(()=>{e===a&&(p=!1)})};S.onKeyDown(e=>{let t=e.browserEvent;t.metaKey||t.ctrlKey||t.altKey||m&&C()});let T=e=>{let t=e.target;t instanceof Node&&!g(t)&&h()};document.addEventListener(`pointerdown`,T,!0),v=()=>{document.removeEventListener(`pointerdown`,T,!0)},S.onDidBlurEditorText(()=>{queueMicrotask(()=>{if(t.disposed||S.hasTextFocus())return;let e=document.activeElement;e&&g(e)||h()})}),S.onDidChangeModelContent(()=>{if(d.current.setting)return;w();let e=S.getValue();d.current.dirty=e!==c.current,n&&clearTimeout(n),n=setTimeout(()=>{let t=s.current(e);d.current.spans=t.spans,d.current.errors=t.errors,y()},pt)}),y()})(),()=>{t.disposed=!0,v?.(),h(),n&&clearTimeout(n);let e=d.current.editor?.getModel();d.current.editor?.dispose(),e?.dispose(),d.current.editor=void 0}},[]),(0,Q.useEffect)(()=>{let{editor:n}=d.current;n&&!t&&(d.current.dirty&&n.getValue()!==e||(n.getValue()===e||(d.current.setting=!0,n.setValue(e),d.current.setting=!1),d.current.dirty=!1))},[e,t]),(0,Q.useEffect)(()=>{d.current.editor?.updateOptions({readOnly:n})},[n]),(0,Q.useEffect)(()=>{ht(d.current,i)},[i]),(0,$.jsx)(`div`,{ref:o,className:`studio-fill`})}function _t(e,t,n,r){return{startLineNumber:t,startColumn:n,endLineNumber:t,endColumn:n+1,message:r,severity:e.MarkerSeverity.Error}}function vt(e,t,n){return n.flatMap(n=>{let r=n.field?`${n.nodeId}.${n.field}`:n.nodeId,i=t.find(e=>e.path===r)??(n.field?t.find(e=>e.path===n.field):void 0);return i?[_t(e,i.line,i.column,n.message)]:[]})}function yt({source:e,blocked:t,issues:n,state:r}){let i=(0,Q.useRef)(e);e&&(i.current=e);let a=(0,Q.useCallback)(e=>{let t=re(r.workspace,r.focus);if(!t)return{errors:[{message:`No agent is open.`,line:1,column:1}],spans:[]};let n=ct(e,{...t,toolSpecs:r.workspace.toolSpecs},e=>r.workspace.agents.find(t=>t.identity.agentId.trim()===e)?.key);return n.ok?(r.update(e=>ne(e,r.focus,n.draft,n.registered)),{errors:[],spans:n.spans}):{errors:n.errors,spans:[]}},[r]);return i.current?(0,$.jsx)(`div`,{className:`studio-fill`,children:(0,$.jsx)(gt,{text:e??i.current,hold:e==null,issues:n,onApply:a})}):(0,$.jsx)(ae,{title:`No code yet`,description:`${t??``} to generate the TypeScript.`})}function bt({provider:e,issues:t,state:n,isEditable:r}){let i=(0,Q.useCallback)(t=>{let r=n.workspace.providers.find(t=>t.id===e.id);if(!r)return{errors:[{message:`No provider is open.`,line:1,column:1}],spans:[]};let i=ft(t,r);return i.ok?(n.update(e=>te(e,i.provider)),{errors:[],spans:i.spans}):{errors:i.errors,spans:[]}},[n,e.id]);return(0,$.jsx)(`div`,{className:`studio-fill`,children:(0,$.jsx)(gt,{text:ie(e),hold:!1,isReadOnly:!r||o(e.definition)===void 0,issues:t,onApply:i},e.id)})}export{yt as CodeBody,bt as ProviderCode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{u as t}from"./themeProps-3IqahpCr.js";import{o as n}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{u as t}from"./themeProps-3IqahpCr.js";import{o as n}from"./index-CQx3WisY.js";var r=e(t(),1);function i({payload:e,runtime:t=null,traces:i,onActivity:a},o,s){return(0,r.useMemo)(()=>{let r=t?s(e,t,{traces:i}):o(e,{traces:i});return a?n(r,a):r},[e,t,i,a,o,s])}export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{h as r,n as i,s as a}from"./browser-transport-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,u as n}from"./themeProps-3IqahpCr.js";import{h as r,n as i,s as a}from"./browser-transport-BMGb5bKR.js";import{n as o,t as s}from"./labels-provider-Gus3heEH.js";import{a as c,t as l}from"./Banner-BwxDeFY1.js";import{c as u}from"./reader-BT_YeHdq.js";import{p as d,u as f}from"./tree-Bi2FOU_h.js";import{S as p,a as m,f as h,h as g,i as _,o as v,p as y,r as b,s as x,t as S,v as C,x as w}from"./ConsoleFrame-Dewh6VXK.js";import{i as T,t as E}from"./use-one-call-OZH6wzzP.js";import{$ as D,Q as O,_ as k,g as A,l as j,m as M}from"./index-CQx3WisY.js";import{t as N}from"./studio-console-D2-0qGXG.js";var P=(e,t,n,r)=>e.decide(n,t,r);function F(e){let{iface:t,describeFailure:n}=M(e),{call:r,...i}=E(e,`deciding`,P);return{iface:t,describeFailure:n,...i,decide:r}}var I=e(n(),1),L=t();function R(e,t){let n;try{n=JSON.parse(e)}catch{return{ok:!1,reason:`invalid_json`}}if(n===null)return{ok:!1,reason:`null_state`,state:n};let r=new TextEncoder().encode(JSON.stringify(n)).byteLength;return t!==void 0&&r>t?{ok:!1,reason:`too_large`,bytes:r,state:n}:{ok:!0,state:n,bytes:r}}function z(e,t,n,r){return t.ok?n===void 0?null:e(`@theorem.decision.state_size`,{size:r(t.bytes),limit:r(n)}):t.reason===`too_large`?e(`@theorem.decision.too_large`,{limit:r(n??0)}):e(t.reason===`invalid_json`?`@theorem.decision.invalid_json`:`@theorem.decision.null_state`)}function B(e){return e.failure||e.result?`settled`:e.status===`deciding`?`waiting`:`idle`}function V(e,t){let[n,r]=(0,I.useState)(e),i=R(n,t),[a,o]=(0,I.useState)(()=>i.state===void 0?`json`:`fields`);return{text:n,setText:r,check:i,shown:i.state===void 0?`json`:a,setView:o}}function H({form:e,iface:t,images:n,onImages:r,note:i,isRunning:a,onRun:s,onStop:c}){let l=o(),{text:u,setText:d,check:f,shown:m,setView:x}=e,S=t.questions.some(e=>e.type===`box`)||Object.keys(n).length>0,w=m===`fields`?f.state:void 0,T=p(w);return(0,L.jsxs)(_,{title:l(`@theorem.decision.state`),view:m,hasFields:f.state!==void 0,onView:x,onRun:s,children:[w===void 0?(0,L.jsx)(b,{label:l(`@theorem.decision.state`),text:u,isInvalid:!f.ok,onChange:d}):(0,L.jsx)(y,{value:{images:n,onImages:r},children:(0,L.jsx)(h,{label:l(`@theorem.decision.state`),value:w,onChange:e=>{d(JSON.stringify(e,null,2))}})}),S&&T?(0,L.jsx)(g,{onImages:e=>{let i=C(e,{images:n,host:t.images,state:T});r(i.images),d(JSON.stringify(i.state,null,2))}}):null,(0,L.jsx)(v,{note:i,isReady:f.ok,isRunning:a,runLabel:l(`@theorem.decision.decide`),runningLabel:l(`@theorem.decision.deciding`),stopLabel:l(`@theorem.decision.stop`),onRun:s,onStop:c})]})}function U({iface:e,decision:t,asked:n,onQuestion:r,questionText:i}){let a=o(),s=t.status===`deciding`;return(0,L.jsxs)(L.Fragment,{children:[t.failure?(0,L.jsx)(l,{status:`error`,role:`alert`,title:t.failure.error}):null,s&&!t.result?(0,L.jsx)(k,{label:a(`@theorem.decision.deciding`),since:t.startedAt}):null,t.result?(0,L.jsx)(T,{iface:e,result:t.result,asked:n,onQuestion:r,questionText:i,elapsedMs:t.elapsedMs,isStale:s}):null]})}function W(e,t,n,r,i){if(t===`idle`)return null;if(!e)return i;let a=t===`waiting`;return(0,L.jsx)(m,{label:n.answers,fill:a,children:a?(0,L.jsx)(k,{label:n.deciding,since:r}):i})}function G({transport:e,iface:t,decision:n,defaultState:r=`{}`,defaultImages:i,onQuestion:a,questionText:s,maxWidth:l=`960px`,trace:u,flush:d,columns:f=!1,className:p,style:m}){let h=o(),g=x(),_=V(r,t.maxStateBytes),{check:v}=_,[y,b]=(0,I.useState)(i??{}),[C,T]=(0,I.useState)(),E=c(t,e.traces,u);return(0,L.jsxs)(S,{inspector:E,maxWidth:l,flush:d,columns:f,requestLabel:h(`@theorem.decision.state`),className:p,style:m,children:[(0,L.jsx)(H,{form:_,iface:t,images:y,onImages:b,note:z(h,v,t.maxStateBytes,g),isRunning:n.status===`deciding`,onRun:()=>{if(!v.ok)return;let e=w(y,v.state);T({images:{...t.images,...e},state:v.state}),n.decide(v.state,Object.keys(e).length>0?e:void 0)},onStop:n.cancel}),W(f,B(n),{answers:h(`@theorem.decision.answers`),deciding:h(`@theorem.decision.deciding`)},n.startedAt,(0,L.jsx)(U,{iface:t,decision:n,asked:C,onQuestion:a,questionText:s}))]})}function K(e){let t=o(),n=F(e.transport);return n.describeFailure?(0,L.jsx)(A,{title:n.describeFailure.error}):n.iface?(0,L.jsx)(G,{...e,iface:n.iface,decision:n}):(0,L.jsx)(k,{label:t(`@theorem.chat.loading`)})}function q({endpoint:e,http:t,transport:n,theme:r,mode:i,labels:o,...c}){let l=(0,I.useRef)(t);l.current=t;let d=(0,I.useMemo)(()=>n??u({...l.current,endpoint:e}),[n,e]);return(0,L.jsx)(a,{theme:r,mode:i,children:(0,L.jsx)(s,{labels:o,children:(0,L.jsx)(K,{...c,transport:d})})})}var J;function Y(e){if(e.agentId===`pantry.jev`)return J??=D(),{defaultState:O,defaultImages:{...(0,I.use)(J)}};let{profile:t}=e;return{defaultState:(t.type===`decision`?Object.values(t.models)[0]:void 0)?.apiId.startsWith(`respan/`)?d:f}}function X(e){return typeof e==`string`?e:Array.isArray(e)?e.map(X).join(` `):Object.entries(e).map(([e,t])=>`${e}: ${X(t)}`).join(` `)}function Z(e){let t=N(e,r,i);return(0,L.jsx)(Q,{...e,transport:t})}function Q({payload:e,transport:t,trace:n,flush:r,columns:i,className:a}){let{open:o}=(0,I.useContext)(j),s=Y(e),{questions:c}=e,l=(0,I.useMemo)(()=>c&&Object.fromEntries(Object.entries(c).map(([e,t])=>[e,X(t.instructions)])),[c]);return(0,L.jsx)(q,{transport:t,...s,trace:n,flush:r,columns:i,className:a,onQuestion:o,questionText:l})}export{Q as DecisionView,Z as StudioDecision};
|