@datalayer/agent-runtimes 1.3.114 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed/chunks/ChatView-CaBuPTyG.js +32 -0
- package/dist-embed/chunks/{DeckComponent-CuRWiARr.js → DeckComponent-cRJJMGgt.js} +1 -1
- package/dist-embed/chunks/{DocumentView-BYU2HREd.js → DocumentView-CiqN9ze6.js} +1 -1
- package/dist-embed/chunks/{EphemeralDocument-BjFSuQKH.js → EphemeralDocument-BjJfn7J-.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawComponent-CFLnMPnf.js → ExcalidrawComponent-BtNXWUN8.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawModal-CB9d5Vpk.js → ExcalidrawModal-C6SEKFlD.js} +1 -1
- package/dist-embed/chunks/{JupyterLexicalExtension-CYnZrelh.js → JupyterLexicalExtension-BuRLImy5.js} +5 -5
- package/dist-embed/chunks/{NotebookToolSurfaces-D62q-lbb.js → NotebookToolSurfaces-ktcGRm7d.js} +1 -1
- package/dist-embed/chunks/{Output-2KxoKu5F.js → Output-BscOPLqE.js} +10 -10
- package/dist-embed/chunks/{YouTubePlugin-CjODyxZ2.js → YouTubePlugin-xBjNr2Iu.js} +1 -1
- package/dist-embed/chunks/{ar-SA-G6X2FPQ2-C-zAYgA-.js → ar-SA-G6X2FPQ2-BB82iKLz.js} +1 -1
- package/dist-embed/chunks/{az-AZ-76LH7QW2-BHq5js6U.js → az-AZ-76LH7QW2-DsMRKXlw.js} +1 -1
- package/dist-embed/chunks/{bg-BG-XCXSNQG7-BTcNNcTc.js → bg-BG-XCXSNQG7-43Y1kPxa.js} +1 -1
- package/dist-embed/chunks/{bn-BD-2XOGV67Q-DXRk27u1.js → bn-BD-2XOGV67Q-CLqPJBll.js} +1 -1
- package/dist-embed/chunks/{ca-ES-6MX7JW3Y-D-0J9rqp.js → ca-ES-6MX7JW3Y-CDFGSEh3.js} +1 -1
- package/dist-embed/chunks/{cs-CZ-2BRQDIVT-CgN3I-57.js → cs-CZ-2BRQDIVT-ByNB8eZd.js} +1 -1
- package/dist-embed/chunks/{da-DK-5WZEPLOC-CHQloSoX.js → da-DK-5WZEPLOC-B7MrVwy8.js} +1 -1
- package/dist-embed/chunks/{de-DE-XR44H4JA-C-Hq84pe.js → de-DE-XR44H4JA-CN1cdk94.js} +1 -1
- package/dist-embed/chunks/{el-GR-BZB4AONW-MTzGcSsP.js → el-GR-BZB4AONW-DnaGhWD1.js} +1 -1
- package/dist-embed/chunks/{es-ES-U4NZUMDT-Thj-4Rwn.js → es-ES-U4NZUMDT-DE1vZzDE.js} +1 -1
- package/dist-embed/chunks/{eu-ES-A7QVB2H4-BEEyNQo-.js → eu-ES-A7QVB2H4-DmHB0zpm.js} +1 -1
- package/dist-embed/chunks/{fa-IR-HGAKTJCU-CtUGmNBZ.js → fa-IR-HGAKTJCU-CNzE8tJj.js} +1 -1
- package/dist-embed/chunks/{fi-FI-Z5N7JZ37-6GMgpkSu.js → fi-FI-Z5N7JZ37-Ca2vTFQC.js} +1 -1
- package/dist-embed/chunks/{fr-FR-RHASNOE6-BakNCbxj.js → fr-FR-RHASNOE6-B0yWFX3_.js} +1 -1
- package/dist-embed/chunks/{gl-ES-HMX3MZ6V-Cwkb9OPk.js → gl-ES-HMX3MZ6V-2_3FMVJq.js} +1 -1
- package/dist-embed/chunks/{he-IL-6SHJWFNN-BaMmvCkr.js → he-IL-6SHJWFNN-BW1lby00.js} +1 -1
- package/dist-embed/chunks/{hi-IN-IWLTKZ5I-1aWewhep.js → hi-IN-IWLTKZ5I-DTixfSwB.js} +1 -1
- package/dist-embed/chunks/{hu-HU-A5ZG7DT2-BIHI23BQ.js → hu-HU-A5ZG7DT2-DOfYwLWP.js} +1 -1
- package/dist-embed/chunks/{id-ID-SAP4L64H-CYpgmx8X.js → id-ID-SAP4L64H-Cwtdtkvg.js} +1 -1
- package/dist-embed/chunks/{index-BhSMzuKq.js → index--qMT5k1q.js} +1 -1
- package/dist-embed/chunks/{index-b1yzCiTq.js → index-B-UP9DlM.js} +1 -1
- package/dist-embed/chunks/{index-DMKsCn-y.js → index-BAwsCLGT.js} +1 -1
- package/dist-embed/chunks/{index-BUhqZVtg.js → index-BITOMOWN.js} +1 -1
- package/dist-embed/chunks/{index-1wTrAXI1.js → index-B_9UD0bt.js} +2 -2
- package/dist-embed/chunks/{index-DtlUttQj.js → index-BgFbP5P0.js} +1 -1
- package/dist-embed/chunks/{index-CC-Ht79i.js → index-CMUTS_sA.js} +1 -1
- package/dist-embed/chunks/{index-B7nmHsEo.js → index-Cgf7tlW3.js} +1 -1
- package/dist-embed/chunks/{index-CsZ2HycN.js → index-CrNfUmIU.js} +1 -1
- package/dist-embed/chunks/{index-DIOcQUrz.js → index-CzuLxFBK.js} +1 -1
- package/dist-embed/chunks/{index-EmZm7_bH.js → index-DEn5R18M.js} +1 -1
- package/dist-embed/chunks/{index-DeVZ-nmF.js → index-DFEBhySA.js} +1 -1
- package/dist-embed/chunks/{index-CMYyiALV.js → index-DYkwi0aX.js} +1 -1
- package/dist-embed/chunks/{index-Fzz2KjFM.js → index-DvpdAlVH.js} +1 -1
- package/dist-embed/chunks/{index-W7TVoWP5.js → index-Dyh5xopp.js} +1 -1
- package/dist-embed/chunks/{index-en9Yf1Yz.js → index-Jt4bWLoz.js} +1 -1
- package/dist-embed/chunks/{index-BbucLMre.js → index-S-sjhoD3.js} +1 -1
- package/dist-embed/chunks/{index-D18sf241.js → index-TRLGqZaF.js} +1 -1
- package/dist-embed/chunks/{index-ZZnjmFwm.js → index-YcqCoWJl.js} +1 -1
- package/dist-embed/chunks/{index-BFLtEBuP.js → index-sQy5cmWo.js} +1 -1
- package/dist-embed/chunks/{it-IT-JPQ66NNP-CLcqplyX.js → it-IT-JPQ66NNP-C3xZ61-6.js} +1 -1
- package/dist-embed/chunks/{ja-JP-DBVTYXUO-u8Qe6tR7.js → ja-JP-DBVTYXUO-CeTmglEb.js} +1 -1
- package/dist-embed/chunks/{kaa-6HZHGXH3-BG2kx50I.js → kaa-6HZHGXH3-D6Jr6B6Y.js} +1 -1
- package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-CSYUpRxd.js → kab-KAB-ZGHBKWFO-pEXBqeuG.js} +1 -1
- package/dist-embed/chunks/{kk-KZ-P5N5QNE5-CpBMgHAz.js → kk-KZ-P5N5QNE5-BRJunmHm.js} +1 -1
- package/dist-embed/chunks/{km-KH-HSX4SM5Z-CoMUUQMb.js → km-KH-HSX4SM5Z--GJgT9rN.js} +1 -1
- package/dist-embed/chunks/{ko-KR-MTYHY66A-DwxY8CGI.js → ko-KR-MTYHY66A-Bjnez4qR.js} +1 -1
- package/dist-embed/chunks/{ku-TR-6OUDTVRD-UoNYUfm0.js → ku-TR-6OUDTVRD-DgOdYJrS.js} +1 -1
- package/dist-embed/chunks/{lt-LT-XHIRWOB4-Dr4uXaEj.js → lt-LT-XHIRWOB4-BMwhrtjM.js} +1 -1
- package/dist-embed/chunks/{lv-LV-5QDEKY6T-CNC56J-_.js → lv-LV-5QDEKY6T-0pxW7YE0.js} +1 -1
- package/dist-embed/chunks/{mr-IN-CRQNXWMA-BKWa9nzZ.js → mr-IN-CRQNXWMA-tndp8BXC.js} +1 -1
- package/dist-embed/chunks/{my-MM-5M5IBNSE-bwAzOWhV.js → my-MM-5M5IBNSE-sispDhO4.js} +1 -1
- package/dist-embed/chunks/{nb-NO-T6EIAALU-CkpsChor.js → nb-NO-T6EIAALU-CjBurOuS.js} +1 -1
- package/dist-embed/chunks/{nl-NL-IS3SIHDZ-COVk4rlb.js → nl-NL-IS3SIHDZ-B58EVmr3.js} +1 -1
- package/dist-embed/chunks/{nn-NO-6E72VCQL-DlyFF-C1.js → nn-NO-6E72VCQL-D1p7LZSq.js} +1 -1
- package/dist-embed/chunks/{oc-FR-POXYY2M6-CFDosV2C.js → oc-FR-POXYY2M6-C1M8sddP.js} +1 -1
- package/dist-embed/chunks/{pa-IN-N4M65BXN-BKRB3O0U.js → pa-IN-N4M65BXN-D8ESzASl.js} +1 -1
- package/dist-embed/chunks/{percentages-BXMCSKIN-D7pnqUsZ.js → percentages-BXMCSKIN-BihMTsFR.js} +3 -3
- package/dist-embed/chunks/{pl-PL-T2D74RX3-C5r2Tds7.js → pl-PL-T2D74RX3-DQGe6LHC.js} +1 -1
- package/dist-embed/chunks/{pt-BR-5N22H2LF-CDnT98bW.js → pt-BR-5N22H2LF-CvXBgZQs.js} +1 -1
- package/dist-embed/chunks/{pt-PT-UZXXM6DQ-C6c4SPk1.js → pt-PT-UZXXM6DQ-BMnnlIUJ.js} +1 -1
- package/dist-embed/chunks/{ro-RO-JPDTUUEW-CW6pbzEZ.js → ro-RO-JPDTUUEW-DZ-9UUH7.js} +1 -1
- package/dist-embed/chunks/{ru-RU-B4JR7IUQ-CbaAJG0w.js → ru-RU-B4JR7IUQ-JlRBwjob.js} +1 -1
- package/dist-embed/chunks/{si-LK-N5RQ5JYF-BZkUjpXF.js → si-LK-N5RQ5JYF-Bx8kHnkd.js} +1 -1
- package/dist-embed/chunks/{sk-SK-C5VTKIMK-DsfWgpPU.js → sk-SK-C5VTKIMK-xsfEfbZb.js} +1 -1
- package/dist-embed/chunks/{sl-SI-NN7IZMDC-Kx0FqxKU.js → sl-SI-NN7IZMDC-SQYUECnr.js} +1 -1
- package/dist-embed/chunks/{subset-shared.chunk-DM3l9OuH.js → subset-shared.chunk-Ch6j8nKC.js} +1 -1
- package/dist-embed/chunks/{subset-worker.chunk-4w4yibm3.js → subset-worker.chunk-pJjck5pR.js} +1 -1
- package/dist-embed/chunks/{sv-SE-XGPEYMSR-DY0ryO-L.js → sv-SE-XGPEYMSR-BxcjSHE2.js} +1 -1
- package/dist-embed/chunks/{ta-IN-2NMHFXQM-CWpIs0i0.js → ta-IN-2NMHFXQM-rItSkDUS.js} +1 -1
- package/dist-embed/chunks/{th-TH-HPSO5L25-Cwkcfb3u.js → th-TH-HPSO5L25-B7UzESFj.js} +1 -1
- package/dist-embed/chunks/{tr-TR-DEFEU3FU-BqJZZl-Y.js → tr-TR-DEFEU3FU-Ci6oNfEX.js} +1 -1
- package/dist-embed/chunks/{uk-UA-QMV73CPH-Dg213mG4.js → uk-UA-QMV73CPH-C9csqvO6.js} +1 -1
- package/dist-embed/chunks/{vi-VN-M7AON7JQ-DY94NKxF.js → vi-VN-M7AON7JQ-DRAj2kZj.js} +1 -1
- package/dist-embed/chunks/{zh-CN-LNUGB5OW-B6I9A7sA.js → zh-CN-LNUGB5OW-DLOyW8hH.js} +1 -1
- package/dist-embed/chunks/{zh-HK-E62DVLB3-D3oqgDOt.js → zh-HK-E62DVLB3-DwC6_2Ws.js} +1 -1
- package/dist-embed/chunks/{zh-TW-RAJ6MFWO-CYwgY0Jo.js → zh-TW-RAJ6MFWO-DEMugIwa.js} +1 -1
- package/dist-embed/datalayer-app-main.js +156 -156
- package/lib/apps/apps/appspec.d.ts +13 -0
- package/lib/apps/apps/appspec.js +93 -0
- package/lib/apps/apps/checks.d.ts +1 -1
- package/lib/apps/apps/checks.js +2 -2
- package/lib/apps/apps/customComponents.js +1 -1
- package/lib/apps/core/canvasBlocks.d.ts +3 -3
- package/lib/apps/core/canvasParts.d.ts +6 -4
- package/lib/apps/core/index.d.ts +8 -0
- package/lib/apps/embed/AppEmbed.js +13 -20
- package/lib/apps/embed/embedSession.d.ts +8 -4
- package/lib/apps/embed/embedSession.js +16 -9
- package/lib/apps/embed/hostBridge.d.ts +47 -13
- package/lib/apps/embed/hostBridge.js +135 -18
- package/lib/apps/index.d.ts +1 -1
- package/lib/apps/index.js +1 -1
- package/lib/apps/plugins/a2ui-surface/AnswerShows.d.ts +21 -0
- package/lib/apps/plugins/a2ui-surface/AnswerShows.js +29 -0
- package/lib/apps/plugins/a2ui-surface/SurfaceToolResult.js +4 -7
- package/lib/apps/plugins/a2ui-surface/index.d.ts +2 -1
- package/lib/apps/plugins/a2ui-surface/index.js +10 -1
- package/lib/apps/plugins/a2ui-surface/toolResult.d.ts +20 -11
- package/lib/apps/plugins/a2ui-surface/toolResult.js +27 -11
- package/lib/apps/plugins/app-components/index.d.ts +1 -1
- package/lib/apps/plugins/app-components/index.js +2 -2
- package/lib/apps/plugins/app-elements/AppElements.d.ts +3 -3
- package/lib/apps/plugins/app-elements/AppElements.js +5 -20
- package/lib/apps/plugins/app-elements/QuestionView.d.ts +30 -0
- package/lib/apps/plugins/app-elements/QuestionView.js +70 -0
- package/lib/apps/plugins/app-elements/index.d.ts +7 -4
- package/lib/apps/plugins/app-elements/index.js +14 -5
- package/lib/apps/plugins/app-page/appPageModel.d.ts +6 -8
- package/lib/apps/plugins/app-page/appPageModel.js +0 -2
- package/lib/apps/plugins/app-page/pageRun.d.ts +2 -2
- package/lib/apps/plugins/app-page/pageRun.js +3 -3
- package/lib/apps/plugins/canvas-blocks/index.d.ts +13 -13
- package/lib/apps/plugins/canvas-blocks/index.js +24 -24
- package/lib/apps/plugins/canvas-parts/index.d.ts +7 -1
- package/lib/apps/plugins/canvas-parts/index.js +36 -0
- package/lib/apps/plugins/chat/ChatView.js +29 -3
- package/lib/chat/base/ChatBase.js +264 -43
- package/lib/chat/base/loopElement.d.ts +16 -17
- package/lib/chat/base/loopElement.js +11 -27
- package/lib/chat/base/loopStep.d.ts +15 -15
- package/lib/chat/base/loopStep.js +10 -13
- package/lib/chat/base/loopWindow.d.ts +15 -20
- package/lib/chat/base/loopWindow.js +26 -27
- package/lib/chat/base/uiFiles.d.ts +29 -0
- package/lib/chat/base/uiFiles.js +69 -0
- package/lib/chat/base/uiOps.d.ts +96 -0
- package/lib/chat/base/uiOps.js +251 -0
- package/lib/chat/messages/ChatMessageList.d.ts +13 -1
- package/lib/chat/messages/ChatMessageList.js +4 -4
- package/lib/components/a2ui/datalayer/Chart.d.ts +1 -1
- package/lib/components/a2ui/datalayer/schema.js +1 -1
- package/lib/components/teams/AnswerSurfaces.d.ts +3 -2
- package/lib/components/teams/AnswerSurfaces.js +7 -7
- package/lib/components/teams/useA2ATeam.d.ts +1 -1
- package/lib/config/AgentConfiguration.d.ts +1 -1
- package/lib/examples/ProtocolSignedRequestsExample.d.ts +10 -0
- package/lib/examples/ProtocolSignedRequestsExample.js +41 -0
- package/lib/examples/ProtocolUcpCheckoutExample.d.ts +10 -0
- package/lib/examples/ProtocolUcpCheckoutExample.js +59 -0
- package/lib/examples/example-selector.js +2 -0
- package/lib/examples/exampleGroups.d.ts +1 -1
- package/lib/examples/exampleGroups.js +4 -0
- package/lib/examples/index.d.ts +2 -0
- package/lib/examples/index.js +2 -0
- package/lib/examples/protocols/signedRequestsDemo.d.ts +27 -0
- package/lib/examples/protocols/signedRequestsDemo.js +59 -0
- package/lib/examples/protocols/ucpCheckoutDemo.d.ts +36 -0
- package/lib/examples/protocols/ucpCheckoutDemo.js +68 -0
- package/lib/protocols/AGUIAdapter.d.ts +7 -0
- package/lib/protocols/AGUIAdapter.js +43 -3
- package/lib/protocols/a2a/index.js +1 -0
- package/lib/protocols/agentic-commerce/index.js +1 -0
- package/lib/protocols/core.d.ts +6 -0
- package/lib/protocols/mcp/index.js +1 -0
- package/lib/protocols/pact/index.js +1 -0
- package/lib/protocols/ucp/index.js +1 -0
- package/lib/protocols/ucp/merchant.d.ts +15 -0
- package/lib/protocols/ucp/merchant.js +257 -0
- package/lib/protocols/web-bot-auth/index.js +1 -0
- package/lib/specs/agents/agents.js +338 -169
- package/lib/specs/apps.js +134 -6
- package/lib/specs/appspecSchema.js +59 -0
- package/lib/specs/cogs.js +6 -3
- package/lib/specs/index.d.ts +2 -1
- package/lib/specs/index.js +2 -1
- package/lib/specs/protocols.d.ts +24 -0
- package/lib/specs/protocols.js +197 -0
- package/lib/specs/ui.d.ts +21 -0
- package/lib/specs/{uiPlugins.js → ui.js} +14 -14
- package/lib/types/agentspecs.d.ts +69 -5
- package/lib/types/messages.d.ts +7 -0
- package/lib/types/protocol.d.ts +15 -0
- package/package.json +2 -2
- package/scripts/codegen/generate_agents.py +43 -8
- package/scripts/codegen/generate_protocols.py +207 -0
- package/scripts/codegen/generate_sandbox_agents.py +1 -1
- package/scripts/codegen/{generate_ui_plugins.py → generate_ui.py} +40 -40
- package/scripts/gen_workers.py +2 -2
- package/dist-embed/chunks/ChatView-D41Nx5rC.js +0 -32
- package/lib/chat/base/loopMessage.d.ts +0 -37
- package/lib/chat/base/loopMessage.js +0 -37
- package/lib/specs/uiPlugins.d.ts +0 -21
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
+
# Distributed under the terms of the Modified BSD License.
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Generate Python and TypeScript code from the YAML protocol specifications.
|
|
7
|
+
|
|
8
|
+
One YAML per agent protocol under ``agentspecs/protocols`` (AGENT_PROTOCOLS
|
|
9
|
+
PS-01); an agent spec's or an application's ``protocols`` names the ones it
|
|
10
|
+
speaks (PS-02).
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
python generate_protocols.py \\
|
|
14
|
+
--specs-dir agentspecs/agentspecs/protocols \\
|
|
15
|
+
--python-output agent_runtimes/specs/protocols.py \\
|
|
16
|
+
--typescript-output src/specs/protocols.ts
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import json
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
from typing import Any
|
|
23
|
+
|
|
24
|
+
import yaml
|
|
25
|
+
from versioning import ensure_spec_version, version_suffix
|
|
26
|
+
|
|
27
|
+
LAYERS = ("transport", "consent", "identity", "commerce", "ui")
|
|
28
|
+
STATUSES = ("shipped", "planned")
|
|
29
|
+
BLOCKS = ("pap", "pact", "a2a")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def load_protocol_specs(specs_dir: Path) -> list[dict[str, Any]]:
|
|
33
|
+
"""Every protocol spec of a directory, each named for its id, its layer, status and block known."""
|
|
34
|
+
specs = []
|
|
35
|
+
for yaml_file in sorted(specs_dir.glob("*.yaml")):
|
|
36
|
+
spec = yaml.safe_load(yaml_file.read_text()) or {}
|
|
37
|
+
ensure_spec_version(spec)
|
|
38
|
+
if spec["id"] != yaml_file.stem:
|
|
39
|
+
raise ValueError(
|
|
40
|
+
f"{yaml_file.name}: the file is named for {yaml_file.stem!r}, the spec says {spec['id']!r}"
|
|
41
|
+
)
|
|
42
|
+
if spec["layer"] not in LAYERS or spec["status"] not in STATUSES:
|
|
43
|
+
raise ValueError(
|
|
44
|
+
f"{yaml_file.name}: layer one of {LAYERS}, status one of {STATUSES}"
|
|
45
|
+
)
|
|
46
|
+
if spec.get("appspec_block") not in (None, *BLOCKS):
|
|
47
|
+
raise ValueError(f"{yaml_file.name}: appspec_block one of {BLOCKS}")
|
|
48
|
+
specs.append(spec)
|
|
49
|
+
return specs
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _const(spec: dict[str, Any]) -> str:
|
|
53
|
+
return (
|
|
54
|
+
spec["id"].replace("-", "_").upper()
|
|
55
|
+
+ "_PROTOCOL"
|
|
56
|
+
+ version_suffix(spec["version"])
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _s(value: Any) -> str:
|
|
61
|
+
return json.dumps(" ".join(str(value or "").split()), ensure_ascii=False)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
65
|
+
lines = [
|
|
66
|
+
"# Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
67
|
+
"# Distributed under the terms of the Modified BSD License.",
|
|
68
|
+
'"""',
|
|
69
|
+
"Protocol Catalog.",
|
|
70
|
+
"",
|
|
71
|
+
"The agent protocols Datalayer targets (AGENT_PROTOCOLS PS-01).",
|
|
72
|
+
"",
|
|
73
|
+
"This file is AUTO-GENERATED from YAML specifications.",
|
|
74
|
+
"DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
|
|
75
|
+
'"""',
|
|
76
|
+
"",
|
|
77
|
+
"from typing import Dict, List, Optional",
|
|
78
|
+
"",
|
|
79
|
+
"from agent_runtimes.types import ProtocolPackagesSpec, ProtocolSpec",
|
|
80
|
+
]
|
|
81
|
+
for spec in specs:
|
|
82
|
+
packages = spec.get("packages") or {}
|
|
83
|
+
block = spec.get("appspec_block")
|
|
84
|
+
lines += [
|
|
85
|
+
"",
|
|
86
|
+
f"{_const(spec)} = ProtocolSpec(",
|
|
87
|
+
f" id={_s(spec['id'])},",
|
|
88
|
+
f" version={_s(spec['version'])},",
|
|
89
|
+
f" name={_s(spec['name'])},",
|
|
90
|
+
f" description={_s(spec.get('description'))},",
|
|
91
|
+
f" publisher={_s(spec.get('publisher'))},",
|
|
92
|
+
f" layer={_s(spec['layer'])},",
|
|
93
|
+
f" spec_url={_s(spec.get('spec_url'))},",
|
|
94
|
+
f" spec_version={_s(spec.get('spec_version'))},",
|
|
95
|
+
f" status={_s(spec['status'])},",
|
|
96
|
+
f" connects={_s(spec.get('connects'))},",
|
|
97
|
+
" packages=ProtocolPackagesSpec(",
|
|
98
|
+
f" python={json.dumps(list(packages.get('python') or []))},",
|
|
99
|
+
f" typescript={json.dumps(list(packages.get('typescript') or []))},",
|
|
100
|
+
" ),",
|
|
101
|
+
f" protocol_tools={json.dumps(list(spec.get('protocol_tools') or []))},",
|
|
102
|
+
f" appspec_block={_s(block) if block else 'None'},",
|
|
103
|
+
")",
|
|
104
|
+
]
|
|
105
|
+
lines += [
|
|
106
|
+
"",
|
|
107
|
+
"",
|
|
108
|
+
"PROTOCOL_CATALOGUE: Dict[str, ProtocolSpec] = {",
|
|
109
|
+
*[f" {_s(spec['id'])}: {_const(spec)}," for spec in specs],
|
|
110
|
+
"}",
|
|
111
|
+
"",
|
|
112
|
+
"",
|
|
113
|
+
"def get_protocol(protocol_id: str) -> Optional[ProtocolSpec]:",
|
|
114
|
+
' """A protocol by id, or None."""',
|
|
115
|
+
" return PROTOCOL_CATALOGUE.get(protocol_id)",
|
|
116
|
+
"",
|
|
117
|
+
"",
|
|
118
|
+
"def list_protocols() -> List[ProtocolSpec]:",
|
|
119
|
+
' """Every protocol of the catalogue."""',
|
|
120
|
+
" return list(PROTOCOL_CATALOGUE.values())",
|
|
121
|
+
"",
|
|
122
|
+
]
|
|
123
|
+
return "\n".join(lines)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _t(value: Any) -> str:
|
|
127
|
+
return json.dumps(" ".join(str(value or "").split()), ensure_ascii=False)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
131
|
+
lines = [
|
|
132
|
+
"/*",
|
|
133
|
+
" * Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
134
|
+
" * Distributed under the terms of the Modified BSD License.",
|
|
135
|
+
" */",
|
|
136
|
+
"",
|
|
137
|
+
"/**",
|
|
138
|
+
" * Protocol Catalog.",
|
|
139
|
+
" *",
|
|
140
|
+
" * The agent protocols Datalayer targets (AGENT_PROTOCOLS PS-01).",
|
|
141
|
+
" *",
|
|
142
|
+
" * This file is AUTO-GENERATED from YAML specifications.",
|
|
143
|
+
" * DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
|
|
144
|
+
" */",
|
|
145
|
+
"",
|
|
146
|
+
"import type { ProtocolSpec } from '../types/agentspecs';",
|
|
147
|
+
]
|
|
148
|
+
for spec in specs:
|
|
149
|
+
packages = spec.get("packages") or {}
|
|
150
|
+
block = spec.get("appspec_block")
|
|
151
|
+
lines += [
|
|
152
|
+
"",
|
|
153
|
+
f"export const {_const(spec)}: ProtocolSpec = {{",
|
|
154
|
+
f" id: {_t(spec['id'])},",
|
|
155
|
+
f" version: {_t(spec['version'])},",
|
|
156
|
+
f" name: {_t(spec['name'])},",
|
|
157
|
+
f" description: {_t(spec.get('description'))},",
|
|
158
|
+
f" publisher: {_t(spec.get('publisher'))},",
|
|
159
|
+
f" layer: {_t(spec['layer'])},",
|
|
160
|
+
f" specUrl: {_t(spec.get('spec_url'))},",
|
|
161
|
+
f" specVersion: {_t(spec.get('spec_version'))},",
|
|
162
|
+
f" status: {_t(spec['status'])},",
|
|
163
|
+
f" connects: {_t(spec.get('connects'))},",
|
|
164
|
+
" packages: {",
|
|
165
|
+
f" python: {json.dumps(list(packages.get('python') or []))},",
|
|
166
|
+
f" typescript: {json.dumps(list(packages.get('typescript') or []))},",
|
|
167
|
+
" },",
|
|
168
|
+
f" protocolTools: {json.dumps(list(spec.get('protocol_tools') or []))},",
|
|
169
|
+
*([f" appspecBlock: {_t(block)},"] if block else []),
|
|
170
|
+
"};",
|
|
171
|
+
]
|
|
172
|
+
lines += [
|
|
173
|
+
"",
|
|
174
|
+
"export const PROTOCOL_CATALOGUE: Record<string, ProtocolSpec> = {",
|
|
175
|
+
*[f" {_t(spec['id'])}: {_const(spec)}," for spec in specs],
|
|
176
|
+
"};",
|
|
177
|
+
"",
|
|
178
|
+
"/** A protocol by id. */",
|
|
179
|
+
"export function getProtocol(protocolId: string): ProtocolSpec | undefined {",
|
|
180
|
+
" return PROTOCOL_CATALOGUE[protocolId];",
|
|
181
|
+
"}",
|
|
182
|
+
"",
|
|
183
|
+
"/** Every protocol of the catalogue. */",
|
|
184
|
+
"export function listProtocolSpecs(): ProtocolSpec[] {",
|
|
185
|
+
" return Object.values(PROTOCOL_CATALOGUE);",
|
|
186
|
+
"}",
|
|
187
|
+
"",
|
|
188
|
+
]
|
|
189
|
+
return "\n".join(lines)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def main() -> None:
|
|
193
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
194
|
+
parser.add_argument("--specs-dir", type=Path, required=True)
|
|
195
|
+
parser.add_argument("--python-output", type=Path, required=True)
|
|
196
|
+
parser.add_argument("--typescript-output", type=Path, required=True)
|
|
197
|
+
args = parser.parse_args()
|
|
198
|
+
specs = load_protocol_specs(args.specs_dir)
|
|
199
|
+
args.python_output.write_text(generate_python_code(specs))
|
|
200
|
+
args.typescript_output.write_text(generate_typescript_code(specs))
|
|
201
|
+
print(
|
|
202
|
+
f"Generated {len(specs)} protocols: {args.python_output}, {args.typescript_output}"
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
if __name__ == "__main__":
|
|
207
|
+
main()
|
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
# Distributed under the terms of the Modified BSD License.
|
|
4
4
|
|
|
5
5
|
"""
|
|
6
|
-
Generate Python and TypeScript code from YAML UI
|
|
6
|
+
Generate Python and TypeScript code from YAML UI specifications.
|
|
7
7
|
|
|
8
|
-
A UI
|
|
8
|
+
A UI spec is how an agent's answer becomes an interface rather than text —
|
|
9
9
|
a protocol the host knows how to render (A2UI, MCP Apps, MCP UI). One YAML per
|
|
10
|
-
plugin under ``agentspecs/ui
|
|
11
|
-
one. A
|
|
10
|
+
plugin under ``agentspecs/ui``; an agent spec's ``ui`` names
|
|
11
|
+
one. A UI spec hosts the visual components it renders (LOOP C-13).
|
|
12
12
|
|
|
13
13
|
Usage:
|
|
14
|
-
python
|
|
15
|
-
--specs-dir agentspecs/agentspecs/ui
|
|
16
|
-
--python-output agent_runtimes/specs/
|
|
17
|
-
--typescript-output src/specs/
|
|
14
|
+
python generate_ui.py \\
|
|
15
|
+
--specs-dir agentspecs/agentspecs/ui \\
|
|
16
|
+
--python-output agent_runtimes/specs/ui.py \\
|
|
17
|
+
--typescript-output src/specs/ui.ts
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
20
|
import argparse
|
|
@@ -29,7 +29,7 @@ from versioning import ensure_spec_version, version_suffix
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def load_plugin_specs(specs_dir: Path) -> list[dict[str, Any]]:
|
|
32
|
-
"""Load all UI
|
|
32
|
+
"""Load all UI YAML specifications from a directory."""
|
|
33
33
|
specs = []
|
|
34
34
|
for yaml_file in sorted(specs_dir.glob("*.yaml")):
|
|
35
35
|
with open(yaml_file) as f:
|
|
@@ -44,7 +44,7 @@ def load_plugin_specs(specs_dir: Path) -> list[dict[str, Any]]:
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
def _const_name(plugin_id: str) -> str:
|
|
47
|
-
return plugin_id.replace("-", "_").replace(".", "_").upper() + "
|
|
47
|
+
return plugin_id.replace("-", "_").replace(".", "_").upper() + "_UI"
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
def _py(value: str) -> str:
|
|
@@ -196,12 +196,12 @@ def _py_calls(specs: list[dict[str, Any]]) -> list[str]:
|
|
|
196
196
|
|
|
197
197
|
|
|
198
198
|
def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
199
|
-
"""Generate Python code from UI
|
|
199
|
+
"""Generate Python code from UI specifications."""
|
|
200
200
|
lines = [
|
|
201
201
|
"# Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
202
202
|
"# Distributed under the terms of the Modified BSD License.",
|
|
203
203
|
'"""',
|
|
204
|
-
"UI
|
|
204
|
+
"UI Catalog.",
|
|
205
205
|
"",
|
|
206
206
|
"How an agent's answer becomes an interface: the protocols a host renders.",
|
|
207
207
|
"",
|
|
@@ -211,10 +211,10 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
211
211
|
"",
|
|
212
212
|
"from typing import Any, Callable, Dict, List, Literal, Mapping, Optional, Union",
|
|
213
213
|
"",
|
|
214
|
-
"from agent_runtimes.types import ComponentBindingsSpec, ComponentSpec,
|
|
214
|
+
"from agent_runtimes.types import ComponentBindingsSpec, ComponentSpec, UISpec",
|
|
215
215
|
"",
|
|
216
216
|
"# " + "=" * 76,
|
|
217
|
-
"# UI
|
|
217
|
+
"# UI Definitions",
|
|
218
218
|
"# " + "=" * 76,
|
|
219
219
|
"",
|
|
220
220
|
]
|
|
@@ -222,7 +222,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
222
222
|
const = _const_name(spec["id"]) + version_suffix(spec["version"])
|
|
223
223
|
lines.extend(
|
|
224
224
|
[
|
|
225
|
-
f"{const} =
|
|
225
|
+
f"{const} = UISpec(",
|
|
226
226
|
f" id={_py(spec['id'])},",
|
|
227
227
|
f" version={_py(str(spec['version']))},",
|
|
228
228
|
f" name={_py(spec['name'])},",
|
|
@@ -241,10 +241,10 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
241
241
|
[
|
|
242
242
|
"",
|
|
243
243
|
"# " + "=" * 76,
|
|
244
|
-
"# UI
|
|
244
|
+
"# UI Catalog",
|
|
245
245
|
"# " + "=" * 76,
|
|
246
246
|
"",
|
|
247
|
-
"
|
|
247
|
+
"UI_CATALOGUE: Dict[str, UISpec] = {",
|
|
248
248
|
]
|
|
249
249
|
)
|
|
250
250
|
for spec in specs:
|
|
@@ -256,20 +256,20 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
256
256
|
"}",
|
|
257
257
|
"",
|
|
258
258
|
"",
|
|
259
|
-
"def
|
|
260
|
-
' """The
|
|
261
|
-
" return
|
|
259
|
+
"def get_ui(plugin_id: str) -> UISpec | None:",
|
|
260
|
+
' """The UI an agent spec\'s `ui` names, or None."""',
|
|
261
|
+
" return UI_CATALOGUE.get(plugin_id)",
|
|
262
262
|
"",
|
|
263
263
|
"",
|
|
264
|
-
"def
|
|
265
|
-
" return list(
|
|
264
|
+
"def list_ui() -> list[UISpec]:",
|
|
265
|
+
" return list(UI_CATALOGUE.values())",
|
|
266
266
|
"",
|
|
267
267
|
"",
|
|
268
|
-
"#: The visual components the enabled UI
|
|
268
|
+
"#: The visual components the enabled UI specs render, by the name a",
|
|
269
269
|
"#: surface gives them (LOOP C-13).",
|
|
270
270
|
"COMPONENT_CATALOGUE: Dict[str, ComponentSpec] = {",
|
|
271
271
|
" component.id: component",
|
|
272
|
-
" for plugin in
|
|
272
|
+
" for plugin in UI_CATALOGUE.values()",
|
|
273
273
|
" if plugin.enabled",
|
|
274
274
|
" for component in plugin.components",
|
|
275
275
|
"}",
|
|
@@ -290,7 +290,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
|
|
|
290
290
|
|
|
291
291
|
|
|
292
292
|
def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
293
|
-
"""Generate TypeScript code from UI
|
|
293
|
+
"""Generate TypeScript code from UI specifications."""
|
|
294
294
|
lines = [
|
|
295
295
|
"/*",
|
|
296
296
|
" * Copyright (c) 2025-2026 Datalayer, Inc.",
|
|
@@ -298,7 +298,7 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
298
298
|
" */",
|
|
299
299
|
"",
|
|
300
300
|
"/**",
|
|
301
|
-
" * UI
|
|
301
|
+
" * UI Catalog.",
|
|
302
302
|
" *",
|
|
303
303
|
" * How an agent's answer becomes an interface: the protocols a host renders.",
|
|
304
304
|
" *",
|
|
@@ -306,14 +306,14 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
306
306
|
" * DO NOT EDIT MANUALLY - run 'make specs' to regenerate.",
|
|
307
307
|
" */",
|
|
308
308
|
"",
|
|
309
|
-
"import type { ComponentSpec,
|
|
309
|
+
"import type { ComponentSpec, UISpec } from '../types/agentspecs';",
|
|
310
310
|
"",
|
|
311
311
|
]
|
|
312
312
|
for spec in specs:
|
|
313
313
|
const = _const_name(spec["id"]) + version_suffix(spec["version"])
|
|
314
314
|
lines.extend(
|
|
315
315
|
[
|
|
316
|
-
f"export const {const}:
|
|
316
|
+
f"export const {const}: UISpec = {{",
|
|
317
317
|
f" id: {_ts(spec['id'])},",
|
|
318
318
|
f" version: {_ts(str(spec['version']))},",
|
|
319
319
|
f" name: {_ts(spec['name'])},",
|
|
@@ -326,7 +326,7 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
326
326
|
"",
|
|
327
327
|
]
|
|
328
328
|
)
|
|
329
|
-
lines.append("export const
|
|
329
|
+
lines.append("export const UI_CATALOGUE: Record<string, UISpec> = {")
|
|
330
330
|
for spec in specs:
|
|
331
331
|
lines.append(
|
|
332
332
|
f" {_ts(spec['id'])}: {_const_name(spec['id']) + version_suffix(spec['version'])},"
|
|
@@ -335,18 +335,18 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
335
335
|
[
|
|
336
336
|
"};",
|
|
337
337
|
"",
|
|
338
|
-
"/** The
|
|
339
|
-
"export function
|
|
340
|
-
" return
|
|
338
|
+
"/** The UI an agent spec's `ui` names, or undefined. */",
|
|
339
|
+
"export function getUI(pluginId: string): UISpec | undefined {",
|
|
340
|
+
" return UI_CATALOGUE[pluginId];",
|
|
341
341
|
"}",
|
|
342
342
|
"",
|
|
343
|
-
"export function
|
|
344
|
-
" return Object.values(
|
|
343
|
+
"export function listUI(): UISpec[] {",
|
|
344
|
+
" return Object.values(UI_CATALOGUE);",
|
|
345
345
|
"}",
|
|
346
346
|
"",
|
|
347
|
-
"/** The visual components the enabled UI
|
|
347
|
+
"/** The visual components the enabled UI specs render, by the name a surface gives them (LOOP C-13). */",
|
|
348
348
|
"export const COMPONENT_CATALOGUE: Record<string, ComponentSpec> = Object.fromEntries(",
|
|
349
|
-
" Object.values(
|
|
349
|
+
" Object.values(UI_CATALOGUE)",
|
|
350
350
|
" .filter(plugin => plugin.enabled)",
|
|
351
351
|
" .flatMap(plugin => plugin.components.map(component => [component.id, component])),",
|
|
352
352
|
");",
|
|
@@ -367,13 +367,13 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
|
|
|
367
367
|
|
|
368
368
|
def main():
|
|
369
369
|
parser = argparse.ArgumentParser(
|
|
370
|
-
description="Generate Python and TypeScript code from YAML UI
|
|
370
|
+
description="Generate Python and TypeScript code from YAML UI specifications"
|
|
371
371
|
)
|
|
372
372
|
parser.add_argument(
|
|
373
373
|
"--specs-dir",
|
|
374
374
|
type=Path,
|
|
375
375
|
required=True,
|
|
376
|
-
help="Directory containing UI
|
|
376
|
+
help="Directory containing UI YAML files",
|
|
377
377
|
)
|
|
378
378
|
parser.add_argument(
|
|
379
379
|
"--python-output", type=Path, required=True, help="Output path for Python file"
|
|
@@ -392,7 +392,7 @@ def main():
|
|
|
392
392
|
specs = load_plugin_specs(args.specs_dir)
|
|
393
393
|
if not specs:
|
|
394
394
|
print(
|
|
395
|
-
f"Warning: No UI
|
|
395
|
+
f"Warning: No UI specifications found in {args.specs_dir}",
|
|
396
396
|
file=sys.stderr,
|
|
397
397
|
)
|
|
398
398
|
return
|
|
@@ -402,7 +402,7 @@ def main():
|
|
|
402
402
|
args.typescript_output.parent.mkdir(parents=True, exist_ok=True)
|
|
403
403
|
args.typescript_output.write_text(generate_typescript_code(specs))
|
|
404
404
|
print(f"Generated TypeScript code: {args.typescript_output}")
|
|
405
|
-
print(f"\n✓ Successfully generated code from {len(specs)} UI
|
|
405
|
+
print(f"\n✓ Successfully generated code from {len(specs)} UI specs")
|
|
406
406
|
|
|
407
407
|
|
|
408
408
|
if __name__ == "__main__":
|
package/scripts/gen_workers.py
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import{E as _,eM as eo,r as o,j as t,eN as to,eO as no,bZ as gn,B as f,H as lt,T as W,c as G,ct as Rt,et as Lt,eP as ae,cn as ct,e as oo,eQ as so,eR as ao,e2 as io,eS as ro,aH as lo,dW as En,dU as co,dX as Ft,eT as uo,eU as fo,eV as po,eW as mo,eX as hn,eY as go,eZ as ho,e_ as bo,d2 as xo,a_ as So,e$ as vo,f0 as yo,f1 as Co,f2 as wo,f3 as ko,f4 as jo,x as At,f5 as Eo,f6 as Io,f7 as To,f8 as Ro,f9 as Ao,fa as Po,fb as Mo,fc as $o,fd as Uo,fe as Oo,ff as Lo,fg as Fo,fh as zo,fi as No,fj as _o,fk as Bo,fl as Ho,fm as Wo,fn as Vo,fo as De,fp as Do,fq as Go,fr as Ko,fs as Yo,ft as bn,fu as qo,fv as Ie,fw as Jo,fx as Qo,a$ as dt,fy as Xo,fz as Zo,fA as xn,fB as es,fC as ts,eB as ns,fD as Pt,fE as Te,fF as os,fG as ss,fH as as,fI as is,fJ as rs,fK as ls,fL as cs,fM as ds,fN as us,fO as fs,fP as ps,fQ as ms,fR as Mt,fS as gs,fT as hs,I as bs,fU as xs,fV as Ss,fW as Sn,fX as vs,fY as ys,fZ as Cs,f_ as zt,f$ as ws,g0 as ks,ej as $t,g1 as js,g2 as Es}from"../datalayer-app-main.js";import{S as Is,E as Ts,a as Rs}from"./SignInIcon-4HkE48mS.js";import{F as As,a as Ps,b as Ms}from"./LinkedInGreyIcon-BoWXE-HS.js";function $s(){const n=_(eo);return o.useMemo(()=>n.map(s=>s.value),[n])}const Ut={github:{name:"github",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/github/callback"},google:{name:"google",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/google/callback"},linkedin:{name:"linkedin",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/linkedin/callback"}},vn=()=>{if(typeof document>"u")return"";const n=document.getElementById("datalayer-config-data");if(!n?.textContent)return"";try{const s=JSON.parse(n.textContent);return String(s?.iamUrl||"").replace(/\/$/,"")}catch{return""}},Us=(n,s="Unable to start social sign-in.")=>{if(n instanceof Error&&n.message)return n.message;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"&&"message"in n){const c=n.message;if(typeof c=="string"&&c.trim())return c}return s},Os=ro`
|
|
2
|
-
.signin-input-theme-scope input:-webkit-autofill,
|
|
3
|
-
.signin-input-theme-scope input:-webkit-autofill:hover,
|
|
4
|
-
.signin-input-theme-scope input:-webkit-autofill:focus,
|
|
5
|
-
.signin-input-theme-scope input:-webkit-autofill:active,
|
|
6
|
-
.signin-input-theme-scope input:-webkit-autofill:disabled,
|
|
7
|
-
.signin-input-theme-scope textarea:-webkit-autofill,
|
|
8
|
-
.signin-input-theme-scope textarea:-webkit-autofill:hover,
|
|
9
|
-
.signin-input-theme-scope textarea:-webkit-autofill:focus,
|
|
10
|
-
.signin-input-theme-scope textarea:-webkit-autofill:active,
|
|
11
|
-
.signin-input-theme-scope textarea:-webkit-autofill:disabled {
|
|
12
|
-
-webkit-text-fill-color: var(--fgColor-default) !important;
|
|
13
|
-
caret-color: var(--fgColor-default) !important;
|
|
14
|
-
-webkit-box-shadow: 0 0 0 1000px var(--bgColor-default) inset !important;
|
|
15
|
-
box-shadow: 0 0 0 1000px var(--bgColor-default) inset !important;
|
|
16
|
-
background-color: var(--bgColor-default) !important;
|
|
17
|
-
transition: background-color 9999s ease-in-out 0s !important;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.signin-input-theme-scope input:disabled,
|
|
21
|
-
.signin-input-theme-scope textarea:disabled {
|
|
22
|
-
-webkit-text-fill-color: var(--fgColor-muted) !important;
|
|
23
|
-
-webkit-box-shadow: 0 0 0 1000px var(--bgColor-default) inset !important;
|
|
24
|
-
box-shadow: 0 0 0 1000px var(--bgColor-default) inset !important;
|
|
25
|
-
background-color: var(--bgColor-default) !important;
|
|
26
|
-
opacity: 1 !important;
|
|
27
|
-
}
|
|
28
|
-
`,Ls=({onSignIn:n,onApiKeySignIn:s,loginUrl:c,name:a,title:d="Datalayer OTEL",description:h="Sign in to access the observability dashboard.",icon:x,leadingIcon:C=t.jsx(io,{size:24}),github:p=!1,google:K=!1,linkedin:B=!1,apiKey:Ge=!1,signUp:L=!0,socialSignInNavigationTarget:Z,asDoc:S=!1,fillHeight:I=!0,hideHero:ee=!1,calloutTitle:Re,calloutDescription:Ke,passwordToggleLabel:ie="Sign in with a password",signUpTitle:Nt="Don't have an account?",signUpDescription:Y="Create a free Datalayer account with your email address.",signUpLabel:ut="Sign up with email",signUpHref:Ae="https://datalayer.ai/signup",onSignUp:H,forgotPasswordHref:q="/password",forgotPasswordLabel:Pe="Forgot password?",showForgotPassword:ft=!0,socialButtonMarginTop:y=3,actionButtonMaxWidth:J=320})=>{const te=S&&!ee,Ye=a??(S&&d==="Datalayer OTEL"?"Datalayer Sign In":d),pt=x??(S?t.jsx(Is,{size:24}):C),F=o.useMemo(()=>{if(c)return c;const i=vn();return i?`${i}/api/iam/v1/login`:"/api/iam/v1/login"},[c]),[V,Se]=o.useState(""),[re,mt]=o.useState(""),[qe,le]=o.useState(!1),[ce,Je]=o.useState(!1),[k,ve]=o.useState(!1),[de,Me]=o.useState(!1),[$e,Qe]=o.useState(null),[z,ye]=o.useState(null),[ne,Xe]=o.useState(""),[ue,Ze]=o.useState(null),[Ue,M]=o.useState(null),{enqueueToast:fe}=to(),[pe,E]=o.useState(!1),[Q,oe]=o.useState(""),D=o.useRef(null),Oe=o.useCallback(i=>no()?gn.URLExt.join(gn.PageConfig.getBaseUrl(),i.oauth2CallbackServerRoute):`${window.location.protocol}//${window.location.hostname}${window.location.port?`:${window.location.port}`:""}${i.oauth2CallbackUIRoute}`,[]),me=o.useMemo(()=>{if(typeof window>"u")return"/";const i=`${window.location.pathname}${window.location.search}${window.location.hash}`;return i.startsWith("/")?i:"/"},[]),Ce=o.useCallback(async i=>{if(!de){M(null),Qe(i.name),Me(!0);try{const g=vn(),m=new URLSearchParams({provider:i.name,callback_uri:Oe(i)}),T=Z===void 0?void 0:String(Z||"").trim(),v=T===void 0?me&&me!=="/"?me:void 0:T&&T.startsWith("/")&&!T.startsWith("//")?T:void 0;v&&m.set("post_auth_redirect",v);const Fe=`${g||""}/api/iam/v1/oauth2/authz/url?${m.toString()}`,j=await fetch(Fe),se=await j.json(),ze=se?.autorization_url;if(!j.ok||!ze)throw new Error(se?.message||"Unable to start social sign-in.");window.location.assign(ze)}catch(g){const m=Us(g);M(m),fe(m,{variant:"error"}),Qe(null),Me(!1)}}},[Oe,me,fe,de,Z]);o.useEffect(()=>{pe&&D.current?.focus()},[pe]);const $=o.useCallback(()=>{E(!1),oe("")},[]),gt=o.useCallback(()=>{!Q.trim()||!s||(s(Q.trim()),$())},[Q,s,$]),ht=o.useCallback(()=>{if(H){H();return}window.location.assign(Ae)},[H,Ae]),bt=o.useCallback(()=>{if(q){if(q.startsWith("http://")||q.startsWith("https://")){window.open(q,"_blank","noopener,noreferrer");return}window.location.assign(q)}},[q]),Le=o.useCallback(async()=>{if(!(S||!V||!re||k)){ve(!0),M(null);try{const i=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handle:V,password:re})});if(!i.ok)throw new Error(`HTTP ${i.status}`);const g=await i.json();if(g.success&&g.token){const m=String(g?.user?.id||g?.user?.uid||"").trim();if(!!g?.user?.mfaUrl&&m){ye(m),Ze(g.token),M(null);return}n&&n(g.token,V)}else M(g.message||"Invalid username or password.")}catch(i){M(i instanceof Error?i.message:String(i))}finally{ve(!1)}}},[S,V,re,k,F,n]),ge=o.useCallback(async()=>{if(!(S||k||!z||!ne.trim()||!ue)){ve(!0),M(null);try{const i=new URL(F,window.location.origin),g=i.pathname.endsWith("/api/iam/v1/login")?i.href.replace(/\/api\/iam\/v1\/login$/,""):`${i.origin}`,m=await fetch(`${g}/api/iam/v1/users/${z}/mfa/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userUid:z,code:ne.trim()})}),T=await m.json();if(!m.ok||!T?.success)throw new Error(T?.message||"Failed to validate your MFA code.");n&&n(ue,V)}catch(i){const g=i instanceof Error?i.message:String(i);M(g),fe(g,{variant:"error"})}finally{ve(!1)}}},[S,fe,V,k,F,ne,ue,z,n]),we=o.useCallback(i=>{i.key==="Enter"&&(z?ge():Le())},[z,Le,ge]),he=de||k||S;return t.jsxs(f,{className:"signin-input-theme-scope",display:"flex",alignItems:ee||te||!I?"flex-start":"center",justifyContent:"center",minHeight:ee||te||!I?"auto":"100vh",bg:ee?"transparent":"canvas.default",color:"fg.default",py:ee?0:te?2:4,children:[t.jsx(Os,{}),t.jsxs(f,{width:"100%",maxWidth:440,p:0,children:[!ee&&t.jsxs(t.Fragment,{children:[t.jsxs(f,{display:"flex",alignItems:"center",gap:2,mb:te?2:3,justifyContent:"center",children:[pt,t.jsx(lt,{sx:{fontSize:3},children:Ye})]}),t.jsx(W,{as:"p",sx:{fontSize:1,color:"fg.muted",mb:te?2:3,textAlign:"center"},children:h})]}),(Re||Ke)&&t.jsxs(f,{mb:3,textAlign:"center",children:[Re&&t.jsx(lt,{as:"h3",sx:{fontSize:2,mb:1},children:Re}),Ke&&t.jsx(W,{sx:{color:"fg.muted",fontSize:1},children:Ke})]}),!z&&(p||K||B)&&t.jsxs(t.Fragment,{children:[p&&t.jsx(G,{block:!0,size:"large",leadingVisual:$e==="github"?()=>t.jsx(Rt,{size:"small"}):As,disabled:he,onClick:()=>Ce(Ut.github),sx:{mt:y,maxWidth:J,mx:"auto"},children:"Sign in with GitHub"}),K&&t.jsx(G,{block:!0,size:"large",leadingVisual:$e==="google"?()=>t.jsx(Rt,{size:"small"}):Ps,disabled:he,onClick:()=>Ce(Ut.google),sx:{mt:y,maxWidth:J,mx:"auto"},children:"Sign in with Google"}),B&&t.jsx(G,{block:!0,size:"large",leadingVisual:$e==="linkedin"?()=>t.jsx(Rt,{size:"small"}):Ms,disabled:he,onClick:()=>Ce(Ut.linkedin),sx:{mt:y,maxWidth:J,mx:"auto"},children:"Sign in with LinkedIn"})]}),!z&&!qe&&t.jsx(f,{mt:3,display:"flex",justifyContent:"center",children:t.jsx(G,{leadingVisual:Lt,size:"large",block:!0,disabled:S||k||de,onClick:()=>le(!0),sx:{maxWidth:J,mx:"auto"},children:ie})}),!z&&qe&&t.jsxs(f,{mt:4,children:[t.jsxs(ae,{required:!0,sx:{mb:3},children:[t.jsx(ae.Label,{children:"Username"}),t.jsx(ct,{autoFocus:!0,block:!0,placeholder:"Your username",value:V,disabled:k||S,onChange:i=>Se(i.target.value),onKeyDown:we})]}),t.jsxs(ae,{required:!0,sx:{mb:3},children:[t.jsx(ae.Label,{children:"Password"}),t.jsx(ct,{block:!0,placeholder:"Your password",type:ce?"text":"password",value:re,disabled:k||S,onChange:i=>mt(i.target.value),onKeyDown:we,trailingAction:t.jsx(ct.Action,{onClick:()=>Je(!ce),disabled:k||S,icon:ce?Ts:Rs,"aria-label":ce?"Hide password":"Show password",sx:{color:"var(--fgColor-muted)"}})})]}),t.jsxs(f,{display:"flex",alignItems:"center",justifyContent:"space-between",mt:3,children:[t.jsx(G,{variant:"primary",disabled:k||S||!V||!re,onClick:Le,children:k?"Signing in…":"Sign In"}),ft&&t.jsx(oo,{as:"button",sx:{fontSize:1,cursor:S?"not-allowed":"pointer",background:"none",border:"none",opacity:S?.6:1},onClick:()=>{S||k||bt()},children:Pe})]})]}),z&&t.jsxs(t.Fragment,{children:[t.jsxs(ae,{required:!0,sx:{mb:3,mt:2},children:[t.jsx(ae.Label,{children:"MFA Code"}),t.jsx(ct,{autoFocus:!0,block:!0,placeholder:"Your MFA code",value:ne,disabled:k||S,onChange:i=>Xe(i.target.value),onKeyDown:we})]}),t.jsx(G,{variant:"primary",block:!0,disabled:k||S||!ne.trim(),onClick:ge,sx:{maxWidth:J,mx:"auto"},children:k?"Validating…":"Validate MFA Code"})]}),Ue&&t.jsx(W,{sx:{color:"danger.fg",fontSize:1,mt:3,display:"block"},children:Ue}),L&&t.jsxs(f,{mt:4,pt:4,textAlign:"center",borderTop:"1px solid",borderColor:"border.muted",children:[t.jsx(lt,{as:"h3",sx:{fontSize:2,mb:2},children:Nt}),t.jsx(W,{as:"p",sx:{color:"fg.muted",fontSize:1,mb:3},children:Y}),t.jsx(f,{display:"flex",justifyContent:"center",children:t.jsx(G,{variant:"primary",size:"large",leadingVisual:so,disabled:S||k,onClick:ht,children:ut})})]}),Ge&&s&&t.jsxs(t.Fragment,{children:[t.jsxs(f,{display:"flex",alignItems:"center",gap:2,my:3,children:[t.jsx(f,{flex:1,height:"1px",bg:"border.default"}),t.jsx(W,{sx:{fontSize:0,color:"fg.muted"},children:"or"}),t.jsx(f,{flex:1,height:"1px",bg:"border.default"})]}),t.jsx(G,{block:!0,leadingVisual:Lt,disabled:S||k||de,onClick:()=>E(!0),sx:{maxWidth:J,mx:"auto"},children:"Sign in with an API Key"}),pe&&t.jsx(f,{role:"dialog","aria-modal":"true","aria-labelledby":"signin-api-key-title",onKeyDown:i=>{i.key==="Escape"&&$()},onClick:$,position:"fixed",inset:0,zIndex:200,p:3,bg:"canvas.backdrop",display:"flex",alignItems:"center",justifyContent:"center",children:t.jsxs(f,{as:"form",onClick:i=>i.stopPropagation(),onSubmit:i=>{i.preventDefault(),gt()},width:"min(560px, 100%)",p:3,borderRadius:2,border:"1px solid",borderColor:"border.default",bg:"canvas.overlay",color:"fg.default",boxShadow:"shadow.large",children:[t.jsx(lt,{id:"signin-api-key-title",sx:{fontSize:2,mb:2},children:"Enter your API Key"}),t.jsxs(ae,{required:!0,children:[t.jsx(ae.Label,{children:"API Key"}),t.jsx(ao,{block:!0,required:!0,autoFocus:!0,placeholder:"Paste your API key here",value:Q,onInput:i=>oe(i.currentTarget.value),ref:D})]}),t.jsxs(f,{mt:3,display:"flex",justifyContent:"flex-end",gap:2,children:[t.jsx(G,{type:"button",onClick:$,children:"Cancel"}),t.jsx(G,{type:"submit",variant:"primary",disabled:!Q.trim(),children:"Authenticate"})]})]})})]})]})]})};function Fs(n){const{agentId:s,instructions:c,model:a,frontendTools:d,inference:h,subagents:x,sharing:C,onSubagentEvent:p,modeEffect:K}=n;return{type:"browser-vercel-ai",endpoint:"",agentId:s,enableConfigQuery:!1,options:{instructions:c,model:a,frontendTools:d,inference:h,subagents:x,sharing:C,onSubagentEvent:p,modeEffect:K}}}const yn=lo((n,s)=>({pending:void 0,suggest:(c,a)=>{const d=c.trim();d&&n({pending:{text:d,submit:a?.submit??!1,nonce:(s().pending?.nonce??0)+1}})},consume:()=>n({pending:void 0})}));function zs({agentName:n,sandboxStillRuns:s=!1,temporary:c=!0,onSignedIn:a,onSignUp:d}){const{configuration:h}=En(),x=o.useCallback(C=>{co.getState().checkIAMToken(C),a?.()},[a]);return t.jsx(f,{height:"100%",minHeight:0,overflowY:"auto",bg:"canvas.default",px:4,py:4,children:t.jsxs(f,{maxWidth:440,mx:"auto",children:[t.jsxs(f,{display:"flex",alignItems:"center",justifyContent:"center",gap:2,color:"attention.fg",mb:2,children:[t.jsx(Lt,{size:20}),t.jsx(W,{sx:{fontSize:2,fontWeight:"semibold",color:"fg.default"},children:c?"This demo runs on a shared key":"Your key has expired"})]}),t.jsxs(W,{as:"p",sx:{fontSize:1,color:"fg.muted",textAlign:"center",mb:3},children:[c?`${n??"The agent"} has used the time this key allows. Sign in to point your own agent at it, use your own data, and drop the time limit.`:`${n??"The agent"} stopped because your session ran out.`,s?" Your notebook is still running in this page.":""]}),t.jsx(Ls,{hideHero:!0,fillHeight:!1,calloutTitle:"Sign in to keep going",github:!0,google:!0,linkedin:!0,socialSignInNavigationTarget:typeof window>"u"?void 0:`${window.location.pathname}${window.location.search}`,loginUrl:h?.iamUrl?`${h.iamUrl}/api/iam/v1/login`:void 0,onSignIn:x,onSignUp:d})]})})}const Ns="https://r1.datalayer.run";function _s(n=!0){const{configuration:s}=En(),c=Ft(C=>C.token),a=s?.aiInferenceUrl||Ns,d=uo(a,n&&!c),h=c||d.token,x=o.useMemo(()=>({inferenceUrl:a,token:h||void 0}),[a,h]);return{inference:x,needsSignIn:fo(x),anonymous:d,inferenceUrl:a}}const Bs={name:"general-purpose",description:"A capable generalist for a task none of the specialists covers: research, reasoning, drafting, checking.",instructions:"You are a capable general-purpose assistant. Carry out the task you are given completely and report the result plainly, saying what you could not do."};function Cn(n){const s=n?.subagents;if(!s)return[];const c=(s.subagents??[]).map(a=>{const d=a.ref?po(a.ref):void 0;return{name:a.name,description:a.description||d?.description||a.name,instructions:a.instructions??d?.systemPrompt,model:a.model??d?.model??s.defaultModel,icon:d?.icon}});return s.includeGeneralPurpose?[...c,Bs]:c}function Hs(n){return n.replace(/^datalayer_/,"").replace(/_lexical$/,"")}function Ws(n){const s=Hs(n);return/^executeCodeIn(Notebook|Document)$/.test(s)||/^(read|list)[A-Z]/.test(s)}function Vs(n,s){return n.filter(c=>s?.has(c.name)||Ws(c.name))}function Ds(n,s){const c=a=>s&&a.value.id===`${s}-tools`?0:a.value.id==="notebook-tools"?1:2;return n.map((a,d)=>({entry:a,index:d,rank:c(a)})).sort((a,d)=>a.rank-d.rank||a.index-d.index).map(a=>a.entry)}function Gs(n,s,c){if(!c||!n.endsWith("-tools"))return!1;const a=n.slice(0,-6);return s.has(a)&&a!==c}const Ks={type:"object",properties:{}};function Ys(n,s){const c=new Set(n.toolset);return n.commands.filter(a=>c.has(a.name)).map(a=>({name:a.name,description:a.description,parameters:a.parameters??Ks,location:"frontend",handler:async d=>{if(!s)throw new Error(`${a.name}: the ${n.plugin??n.id} plugin is not mounted on this page.`);const h=Object.keys(d??{}).length>0?d:void 0,x=await s.executeCommand(a.command,h);return x===void 0?{ok:!0,command:a.command,argument:h}:x}}))}function qs(n,s){return n.flatMap(c=>Ys(c,s))}function Js(){const n=mo(),s=$s();return o.useMemo(()=>qs(s,n),[s,n])}const wn={opening:"Opening your conversation…",notOpened:n=>`Your conversation could not be opened, so this is a new one: ${n}`};function Qs(n){let s;for(const c of n.split(/\r?\n\r?\n/)){const a=c.split(/\r?\n/).filter(d=>d.startsWith("data:")).map(d=>d.slice(5).trim()).join("");if(a)try{const d=JSON.parse(a);d.type==="MESSAGES_SNAPSHOT"&&Array.isArray(d.messages)&&(s=d.messages)}catch{}}return s}async function kn(n){try{const s=await n.json();if(typeof s.detail=="string"&&s.detail)return s.detail}catch{}return`${n.status}`}async function Xs({agentBaseUrl:n,agentId:s,uid:c,token:a,fetcher:d=fetch}){const h=`${n.replace(/\/+$/,"")}/api/v1/apps/sessions/${encodeURIComponent(c)}`,x=a?{Authorization:`Bearer ${a}`}:{},C=await d(`${h}/messages`,{headers:x});if(C.ok){const B=await C.json();return hn(B.messages)}if(C.status!==404)throw new Error(await kn(C));const p=await d(`${h}/resume`,{method:"POST",headers:{"Content-Type":"application/json",...x},body:JSON.stringify({agent:s})});if(!p.ok)throw new Error(await kn(p));const K=Qs(await p.text());if(!K)throw new Error(`The runtime said nothing of session ${c}.`);return hn(K)}const Zs="var(--theme-accent)";function In({face:n,size:s}){return typeof n=="string"?t.jsx(go,{emoji:n,size:s,label:""}):t.jsx(t.Fragment,{children:n})}function ea({face:n,size:s,state:c}){const a=c==="thinking"||c==="working",d=c==="paused";return t.jsxs(f,{as:"span","aria-hidden":!0,"data-presence":c,position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:s+8,height:s+8,flexShrink:0,fontSize:s,lineHeight:1,children:[t.jsx(f,{as:"span",position:"absolute",inset:0,borderRadius:"50%",boxShadow:d?"none":`0 0 0 2px ${Zs}`,border:d?"2px dashed":"none",borderColor:"border.default",opacity:a||c==="waiting"||d?.9:0,transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",animation:a?"loopPresenceBreath 1.8s ease-in-out infinite":"none",reducedMotion:{animation:"none"},sx:{"@keyframes loopPresenceBreath":{"0%, 100%":{transform:"scale(0.92)",opacity:.35},"50%":{transform:"scale(1.06)",opacity:.9}}}}),t.jsx(f,{as:"span",display:"inline-flex",opacity:d?.55:1,filter:d?"grayscale(0.6)":"none",transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",children:t.jsx(In,{face:n,size:s})})]})}function ta({state:n}){return t.jsx(W,{role:"status","aria-live":"polite","data-presence-line":n,sx:{fontSize:0,color:n==="waiting"?"fg.default":"fg.muted",fontWeight:n==="waiting"?"semibold":"normal",whiteSpace:"nowrap",flexShrink:0},children:ho[n]})}const na=zt(void 0),oa=zt(""),sa=zt({}),X="",aa=1400,jn=parseInt(js["--loop-face-large"],10);function da({workspace:n}){const s=bo(),c=xo(),a=o.useRef(null),{setViewControls:d}=n,[h,x]=o.useState(null),C=So(),p=C.getConfig(vo),K=p?.placeholder||s.placeholder,B=p?.defaultSurface??"notebook",Ge=C.getConfig(yo),[L,Z]=o.useState(X),S=o.useRef(!1),I=_(Co),ee=_(wo),Re=_(ko),ie=_(jo)[0]?.value,Y=At(ie?.promptStance??na)??ie?.prompt,ut=_(Eo),Ae=Io(ut[0]?.value),H=o.useRef(Ae);H.current=Ae;const q=o.useRef(""),Pe=_(To),ft=o.useMemo(()=>Ro(()=>Pe.reduce((e,r)=>({...e,...r.value.extras.value}),{})),[Pe]),y=At(Pe.length>0?ft:sa),J=o.useRef(new Set),te=Ao(ws,n),Ye=!te.allowed,pt=Ye?te.reason??"Chat is unavailable for this sandbox":void 0,[F,V]=o.useState(!1),[Se,re]=o.useState(!1),[mt,qe]=o.useState({open:!1,pendingApproval:!1}),le=Po(F,mt,p?.presence?.paused===!0),ce=p?.presence?.onPresence;o.useEffect(()=>{ce?.(le),H.current?.setPresence(le)},[ce,le]);const Je=o.useRef(p?.presence?.onSaying);Je.current=p?.presence?.onSaying;const k=o.useRef({answering:!1}),ve=o.useCallback(e=>{a.current=e,re(!!e)},[]),de=o.useCallback(e=>{const{open:r,pendingApproval:l}=Mo(e);qe(xe=>xe.open===r&&xe.pendingApproval===l?xe:{open:r,pendingApproval:l});const b={saying:Uo(e),answering:$o(e)},u=k.current;(u.saying?.id!==b.saying?.id||u.saying?.text!==b.saying?.text||u.answering!==b.answering)&&(k.current=b,Je.current?.(b));const O=H.current;if(!O)return;O.items(e);const P=new Set(["complete","completed","done","error","failed","cancelled","canceled","rejected","denied","stopped"]),R={insertcell:"adding a cell",updatecell:"editing a cell",runcell:"running a cell",deletecells:"removing cells",readallcells:"reading the notebook",readcell:"reading a cell",executecode:"running code",insertblock:"adding a block",updateblock:"editing a block",runblock:"running a block",readdocument:"reading the document"};let w;for(let xe=e.length-1;xe>=0;xe-=1){const rt=e[xe];if(typeof rt.toolName=="string"&&rt.toolCallId){P.has(String(rt.status).toLowerCase())||(w=rt);break}}if(!w){O.activity(void 0);return}const Tt=w.toolName.toLowerCase().replace(/^datalayer_/,"").replace(/_lexical$/,"").replace(/[^a-z]/g,""),Zn=R[Tt]??`using ${w.toolName}`;O.activity(`${q.current||"The agent"} is ${Zn}…`)},[]),Me=o.useRef(y);Me.current=y;const $e=o.useCallback(e=>{Ln(e),H.current?.usage(e),Me.current.onUsage?.(e)},[]),Qe=o.useCallback(e=>{V(e),e||H.current?.end("done")},[]),z=o.useCallback(e=>{const r=H.current;if(!r)return;let l=-1;for(let u=e.length-1;u>=0;u-=1)if(e[u].role==="user"){l=u;break}const b=e.slice(l+1).filter(u=>u.role==="assistant").map(Oo).filter(u=>u.trim().length>0).join(`
|
|
29
|
-
|
|
30
|
-
`);r.assistant(b)},[]),ye=o.useRef([]),ne=o.useRef(!1),Xe=o.useRef(void 0),ue=o.useRef(void 0),Ze=_(Lo),Ue=o.useRef(Ze);Ue.current=Ze;const M=o.useCallback((e,r)=>{if(ue.current)return ue.current;const l=Fo(Ue.current.map(O=>O.value),r),b=l?.loop;if(ne.current&&b?.files&&b.files.length>0){const O=Xe.current;if(!O)return"A file is given to an application running on a runtime: run it on Datalayer or on your machine to give it one.";let P;try{P=b.files.map(R=>({file:No(String(R.name??"")),base64:zo(String(R.data_url??""))}))}catch(R){return R instanceof Error?R.message:String(R)}O.execute(_o(P)).then(R=>{if(!R.success){x(`The files could not be put in the sandbox: ${R.error??"it failed"}.`);return}M(`${e}
|
|
31
|
-
|
|
32
|
-
${Bo(P.map(w=>w.file))}`,{...l,loop:Object.fromEntries(Object.entries(b).filter(([w])=>w!=="files"))})});return}H.current?.begin(e,a.current?.thread());const u=a.current?.send;if(!u){ye.current.push([e,l]);return}u(e,l)},[]);o.useEffect(()=>{d(Se?{busy:F,stop:a.current?.stop,newChat:a.current?.newChat,send:M}:null)},[F,Se,d,M]),o.useEffect(()=>()=>d(null),[d]),o.useEffect(()=>n.prompts.subscribe(M),[n.prompts,M]),o.useEffect(()=>{if(!Se||ye.current.length===0)return;const e=ye.current.splice(0,ye.current.length);for(const[r,l]of e)a.current?.send(r,l)},[Se]);const fe=o.useRef(!1),pe=o.useCallback(async e=>{fe.current||(fe.current=!0,Ge?.firstPromptHook?.()),x(null);const r=await n.submit(e);if(!r.handled){x(r.reason??null);return}jt(""),r.result?.content&&x(r.result.content)},[n,Ge?.firstPromptHook]),E=o.useMemo(()=>I.find(e=>e.value.surfaceId===L)?.value,[I,L]),Q=o.useCallback(e=>{S.current=!0,Z(e)},[]);o.useEffect(()=>Ho(Q),[Q]),o.useEffect(()=>{Wo(I.map(e=>e.value.surfaceId))},[I]),o.useEffect(()=>{Vo(L&&L!==X?L:Es)},[L]);const oe=o.useMemo(()=>B===X||B==="none"?void 0:I.find(e=>e.value.surfaceId===B),[I,B]);o.useEffect(()=>{S.current||!oe||De(oe.value,n)&&Z(B)},[oe,n,B]);const[D,Oe]=o.useState(null),me=o.useRef(null),Ce=p?.fullScreenTopOffset??0,{fullScreen:$,usingApi:gt,toggle:ht,topOffsetPx:bt}=Do(me,{forceOverlay:!!Ce,topOffset:Ce}),[Le,ge]=o.useState(!1),we=o.useRef(!1);o.useEffect(()=>{!F||we.current||$||(we.current=!0,ge(!0))},[F,$]),o.useEffect(()=>{$&&ge(!1)},[$]),o.useEffect(()=>{E&&!De(E,n)&&(Oe(E.surfaceId),Z(X))},[E,n]);const he=o.useMemo(()=>{if(D)return I.find(e=>e.value.surfaceId===D)?.value;if(!S.current&&L===X)return oe?.value},[I,D,L,oe]);o.useEffect(()=>{if(!D||L!==X)return;const e=I.find(r=>r.value.surfaceId===D);e&&De(e.value,n)&&(Oe(null),Z(D))},[I,L,D,n]);const i=n.agentId?.trim()||"default",g=Go(n.sandbox.target??"local");ne.current=g;const m=Ko(),T=At(m?.selected??oa),v=m?.members.find(e=>e.id===T),xt=_(Yo)[0]?.value,Fe=xt?.specId,j=bn(v?.specId??i)??(Fe?bn(Fe):void 0),se=v?void 0:xt,ze=g&&!v?Cs(Fe,j):void 0;q.current=v?.name??j?.name??i;const _t=_(qo),Bt=y.hiddenOpeners,Ht=y.hideOpeners,St=y.openers,vt=o.useMemo(()=>{if(Ht)return[];const e=new Set(Bt??[]),r=w=>e.size===0?w:w.filter(Tt=>!e.has(Tt.text));if(St)return r(St);const l=_t.flatMap(w=>w.value.suggestions);if(l.length>0)return r(l);const b=r(j?.suggestions??[]),u=r(m?.team.suggestions??[]);if(u.length===0)return b;const O=new Set(u.map(w=>w.text)),P=m?.team.name??"Team",R=v?.name??j?.name??i;return[...u.map(w=>({...w,group:P})),...b.filter(w=>!O.has(w.text)).map(w=>({...w,group:R}))]},[_t,m,j,v,i,Bt,Ht,St]),et=o.useMemo(()=>vt.map(e=>({title:e.summary??e.text,message:e.message??e.text,group:e.group})),[vt]),yt=Ie(j?.icon),N=p?.presence,Tn=Ie(m?.team.icon),Wt=_(Jo),tt=o.useMemo(()=>{const e=[],r=new Map,l=new Set,b=new Set(I.map(u=>u.value.surfaceId));for(const u of Ds(Wt,E?.surfaceId)){if(Gs(u.value.id,b,E?.surfaceId))continue;let O;try{O=u.value.tools(n)}catch(P){console.warn(`[loop] frontend tools from '${u.plugin}' failed:`,P);continue}for(const P of O){const R=r.get(P.name);if(R){console.warn(`[loop] frontend tool '${P.name}' from '${u.plugin}' is shadowed by the one from '${R}'.`);continue}r.set(P.name,u.plugin),e.push(P),u.value.chatView&&l.add(P.name)}}for(const u of y.frontendTools??[])r.has(u.name)||(r.set(u.name,"chat-extras"),e.push(u),l.add(u.name));return E?e:Vs(e,l)},[Wt,n.surfaceId,n.agentId,y.frontendTools,E?.surfaceId,I]),Ct=Js(),Ne=o.useMemo(()=>{if(Ct.length===0)return tt;const e=new Set(tt.map(r=>r.name));return[...tt,...Ct.filter(r=>!e.has(r.name))]},[tt,Ct]);Xe.current=g&&Ne.some(e=>e.name===Qo)?C.getOutput(dt)?.sandbox:void 0;const A=Xo(n.sandbox,n.serverUrl),Vt=_(Zo),Rn=o.useMemo(()=>Vt.filter(e=>e.value.composer).map(e=>({name:e.value.name,description:e.value.description})),[Vt]),An=o.useMemo(()=>{if(!m||!v)return Cn(j).map(l=>({name:l.name,description:l.description,icon:Ie(l.icon)}));const e=m.members.map(l=>({name:l.name,description:l.description,emoji:l.emoji,icon:Ie(l.icon),disabled:l.id===v.id,disabledReason:l.id===v.id?`You are already talking to ${l.name}`:void 0})),r=xn(m.team,v.id).filter(l=>!m.members.some(b=>b.name===l.name)).map(l=>({name:l.name,description:l.description,icon:Ie(l.icon)}));return[...e,...r]},[m,v,j]),{inference:Dt,anonymous:Pn}=_s(g),Mn=Ft(e=>e.user),wt=g&&Pn.status==="expired",Gt=!Mn,_e=es();ue.current=_e.disabled?_e.disableReason||"This conversation is closed here.":void 0;const kt=A===void 0?ts(n.sandbox,s):void 0,nt=Ye||wt||!!ze||!!kt||_e.disabled,Kt=wt?Gt?s.demoKeyExpired:s.keyExpired:ze??kt??pt??(_e.disabled?_e.disableReason:void 0),[Yt,jt]=o.useState(""),[$n,qt]=o.useState(),ot=$n??se?.model??j?.model??n.model??"",ke=ns(),Jt=o.useRef(ke),Qt=o.useRef(T),Xt=o.useRef(ke);Xt.current=ke,o.useEffect(()=>{Qt.current!==T&&(Qt.current=T,Jt.current=Xt.current,qt(void 0))},[T]);const Un=ke&&ke!==Jt.current?ke:null,[On,Ln]=o.useState(),Fn=Un??On??null,zn=Pt(Te.inpromptMenu),Nn=Pt(Te.promptAction),_n=Pt(Te.chatHeader),Bn=o.useMemo(()=>m?.members.map(e=>({id:e.id,name:e.name,description:e.description,icon:Ie(e.icon)}))??[],[m]),be=yn(e=>e.pending),[Zt,Hn]=o.useState(0);o.useEffect(()=>os(()=>Hn(e=>e+1)),[]),o.useEffect(()=>{be&&(jt(be.text),yn.getState().consume(),be.submit&&pe(be.text))},[be]);const Be=!!(se?.createPayload?.app_spec||C.getConfig(dt)?.datalayerCreatePayload?.app_spec),Wn=Ft(e=>e.token),en=C.getConfig(dt)?.datalayerVisitors,Vn=ss(en),Dn=C.getConfig(dt)?.embedToken,He=en?Vn.token:Dn||Wn,U=p?.thread,[je,tn]=o.useState(null),Gn=!!(U?.fromRuntime&&je?.given!==U.id);o.useEffect(()=>{if(!U?.fromRuntime||!Be||!A)return;let e=!0;return(async()=>{let r="";for(let l=0;l<4&&e;l+=1)try{const b=await Xs({agentBaseUrl:A,agentId:i,uid:U.id,token:He});e&&tn({given:U.id,thread:{...U,fromRuntime:!1,messages:b}});return}catch(b){r=b instanceof Error?b.message:String(b),await new Promise(u=>setTimeout(u,1500))}e&&tn({given:U.id,thread:{id:as(),messages:[],onStarted:U.onStarted},said:wn.notOpened(r)})})(),()=>{e=!1}},[U?.id,U?.fromRuntime,Be,A,i,He]);const nn=U?.fromRuntime?je?.given===U.id?je.thread:void 0:U,Et=o.useMemo(()=>g?Fs({agentId:v?.specId??i,instructions:is(j,se?.instructions),model:ot||void 0,inference:Dt,frontendTools:Ne,subagents:m&&v?xn(m.team,v.id):Cn(j),sharing:m?.sharing,onSubagentEvent:e=>ks.getState().appendSubagentEvent(e),modeEffect:se?.modeEffect}):A!==void 0?{type:"ag-ui",endpoint:Be?`${A}/api/v1/apps/agents/${encodeURIComponent(i)}/ag-ui/`:`${A}/api/v1/ag-ui/${i}/`,...Be&&He?{authToken:He}:{},agentId:i,configEndpoint:`${A}/api/v1/configure`,enableConfigQuery:!0}:void 0,[i,g,Dt,v,Ne,m,j,se,ot,A,Be,He]),st=rs(!g,Et?.type==="ag-ui"?Et.configEndpoint:void 0,void 0,i),We=ls(),at=cs(i),[on,sn]=o.useState(void 0),[Kn,Yn]=o.useState(void 0);o.useEffect(()=>{if(g||A===void 0)return;let e=!1;return fetch(`${A}/api/v1/configure/models?agent_id=${encodeURIComponent(i)}`).then(r=>r.ok?r.json():null).then(r=>{e||(sn(r?ds(r):[]),Yn(r?us(r):void 0))}).catch(()=>{e||sn([])}),()=>{e=!0}},[A,i,g]);const qn=o.useMemo(()=>fs(on,()=>Object.values(ps).filter(e=>e.available&&ms(e)).map(e=>({id:e.id,name:e.name,provider:e.provider}))),[on]),an=o.useMemo(()=>{const e=st.data?.builtinTools??[],r=new Set(e.map(l=>l.name));return{runtime:e,frontend:Ne.filter(l=>!r.has(l.name)).map(l=>({id:l.name,name:l.name}))}},[st.data?.builtinTools,Ne]),rn=o.useMemo(()=>new Set((We.data?.skills??[]).filter(e=>e.status==="enabled"||e.status==="loaded").map(e=>e.id)),[We.data]),Jn=o.useCallback(async e=>{qt(e),!(g||A===void 0)&&await fetch(`${A}/api/v1/configure/inference/provider`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({model:e})}).catch(()=>{})},[A,g]),ln=p?.promptPlacement==="bottom-chat",Qn=p?.promptPlacement==="floating",Ee=p?.promptPlacement==="top",Ve=p?.hidePrompt===!0||y.hidePrompt===!0,Xn={onSend:()=>{pe(Yt)},input:Yt,setInput:jt,focusTrigger:be||Zt?(be?.nonce??0)+Zt:void 0,placement:Qn||Y==="floating"||Y==="floating-top"||Y==="floating-bottom"?"floating":"docked",floatingAnchor:Y==="floating-top"?"top":"bottom",isLoading:F,onStop:()=>n.viewControls.stop?.(),placeholder:Kt??K,typingSuggestions:vt.map(e=>e.text),suggestions:et,disableInputPrompt:nt,connectionConfirmed:!nt,padding:Ee||Y==="floating-top"||Y==="floating-bottom"||Y==="docked-top"?2:3,promptVariant:"lexical",autoFocus:p?.autoFocusPrompt??!0,mentionableAgents:An,promptCommands:Rn,headerContent:zn.length>0?t.jsx(Mt,{slot:Te.inpromptMenu,props:{workspace:n}}):void 0,footerExtras:Nn.length>0?t.jsx(Mt,{slot:Te.promptAction,props:{workspace:n}}):void 0,showAgentsMenu:!N,showInlineAgentsMenu:!1,agents:Bn,selectedAgentId:T,onSelectAgent:e=>m?.select(e),showTokenUsage:y.showTokenUsage??p?.showTokenUsage??!0,showContextRing:!0,agentUsage:Fn??void 0,showModelSelector:!N,models:qn,decisions:Kn,selectedModel:ot,onModelSelect:e=>{Jn(e)},showToolsMenu:!N,availableTools:an.runtime,availableFrontendTools:an.frontend,mcpServers:st.data?.mcpServers??[],mcpStatusData:y.mcpStatusData??void 0,showSkillsMenu:!N,skills:We.data?.skills??[],skillsLoading:We.isLoading,enabledSkills:rn,onToggleSkill:e=>rn.has(e)?at.disableSkill(e):at.enableSkill(e),onToggleAllSkills:(e,r)=>e.forEach(l=>r?at.enableSkill(l):at.disableSkill(l)),codemodeEnabled:y.codemodeEnabled??!1,onToggleCodemode:y.onToggleCodemode,isA2AProtocol:!1,hasConfigData:!!st.data,hasSkillsData:!!We.data},cn=ee[0]?.value.Component,It=Re[0]?.value.Component,it=cn?t.jsx(cn,{workspace:n,composer:Xn}):null,dn=I.length>0&&p?.showSurfaceSelector!==!1?t.jsx(ia,{surfaces:I.map(e=>e.value),active:E?.surfaceId??he?.surfaceId??X,onChange:Q,workspace:n}):null,un=t.jsxs(t.Fragment,{children:[I.map(e=>{const r=e.value,l=E?.surfaceId===r.surfaceId;return l||J.current.has(r.surfaceId)||De(r,n)?(J.current.add(r.surfaceId),t.jsx(f,{sx:l?{flex:"1 1 0",minWidth:0,minHeight:0}:{position:"absolute",inset:0,visibility:"hidden",pointerEvents:"none",zIndex:-1},children:t.jsx(gs,{load:r.load,props:{surfaceId:r.surfaceId,workspace:n},fallback:t.jsxs(Ot,{children:["Loading ",r.title,"…"]}),errorFallback:u=>t.jsxs(Ot,{children:[r.title," failed to load: ",u.message]})})},r.surfaceId)):null}),!E&&he?t.jsx(f,{flex:"1 1 0",minWidth:0,minHeight:0,children:t.jsxs(Ot,{children:["Starting ",he.title,"…"]})}):null]}),fn=t.jsx(t.Fragment,{children:t.jsxs(f,{flex:Ee&&E?"0 0 34%":"1 1 0",maxWidth:Ee&&E?460:void 0,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",borderLeft:E?"1px solid":void 0,borderColor:"border.default",position:"relative",children:[y.errorBanner?t.jsx(f,{flexShrink:0,px:3,py:2,fontSize:1,borderBottom:"1px solid",bg:y.errorBanner.variant==="warning"?"attention.subtle":"danger.subtle",color:y.errorBanner.variant==="warning"?"attention.fg":"danger.fg",borderColor:y.errorBanner.variant==="warning"?"attention.muted":"danger.muted",children:y.errorBanner.message}):null,je?.said&&je.given===U?.id?t.jsx(W,{as:"p",role:"status",sx:{m:0,px:3,py:2,fontSize:1,color:"fg.muted"},children:je.said}):null,t.jsx(f,{flex:"1 1 auto",minHeight:0,display:"flex",children:Gn?t.jsx(W,{as:"p",role:"status",sx:{m:0,p:3,fontSize:1,color:"fg.muted"},children:wn.opening}):t.jsx(hs,{themeVariant:p?.themeVariant,themeOverrides:p?.themeOverrides,colorMode:p?.colorMode,thread:nn,disabled:nt,disableReason:Kt,protocol:Et,frontendTools:g?void 0:y.frontendTools,initialModel:ot||void 0,title:N?.name??v?.name??j?.name??i,description:N?.welcome??j?.description,brandIcon:N?.face?t.jsx(ea,{face:N.face,size:20,state:le}):t.jsx(yt,{size:20}),headerContent:N&&!kt?t.jsx(ta,{state:le}):void 0,emptyState:{icon:N?.face?t.jsx("span",{"aria-hidden":!0,style:{fontSize:jn,lineHeight:1},children:t.jsx(In,{face:N.face,size:jn})}):t.jsx(yt,{size:48}),title:N?.name??v?.name??j?.name??i,...m&&v?{sections:[{group:m.team.name,icon:t.jsx(Tn,{size:48}),title:m.team.name,subtitle:m.team.description},{group:v.name,icon:t.jsx(yt,{size:32}),title:v.name,subtitle:j?.description}]}:null},suggestions:Ee||ie||p?.suggestionLabels===!1?[]:et,showHeader:!p?.hideHeader&&!!It,headerButtons:{showNewChat:p?.headerButtons?.newChat??!1,showClear:p?.headerButtons?.clear??!1},renderHeader:It?e=>t.jsx(It,{workspace:n,header:e}):void 0,showInformation:!0,headerActions:t.jsxs(f,{display:"inline-flex",alignItems:"center",gap:2,children:[n.chatHeaderActions,_n.length>0?t.jsx(Mt,{slot:Te.chatHeader,props:{workspace:n}}):null,t.jsx(bs,{icon:$?xs:Ss,"aria-label":$?"Exit full screen":"Enter full screen",variant:"invisible",size:"small",onClick:()=>{ge(!1),ht()},sx:Le?{"@keyframes dla-fullscreen-hint":{"0%, 100%":{opacity:1},"50%":{opacity:.4}},"&&":{bg:`color-mix(in srgb, ${c.primary} 16%, transparent)`,boxShadow:`inset 0 0 0 1.5px ${c.primary}`,animation:`dla-fullscreen-hint ${aa}ms ease-in-out infinite`},"@media (prefers-reduced-motion: reduce)":{"&&":{animation:"none"}}}:void 0})]}),showInput:!1,onSendReady:ve,notebookToolSurfacesId:E?void 0:n.surfaceId,showTurnFooter:y.showTokenUsage??p?.showTokenUsage??!0,onContextSnapshot:$e,onLoadingChange:Qe,onItemsChange:z,onDisplayItemsChange:de,enableStreaming:!0},nn?.id)}),ln&&!Ve?it:null]})}),pn=p?.suggestionLabels!==!1&&et.length>0?t.jsx(f,{"aria-label":s.suggestedPrompts,display:"flex",flexWrap:"wrap",gap:2,px:2,pb:"6px",children:et.map(e=>t.jsx(f,{as:"button",type:"button",title:e.message,disabled:F||nt,onClick:()=>{pe(e.message)},appearance:"none",font:"inherit",fontSize:0,fontWeight:"semibold",lineHeight:1.25,px:"10px",py:"5px",width:Sn,flex:`0 0 ${Sn}px`,borderRadius:"999px",border:"1px solid",bg:"canvas.subtle",whiteSpace:"nowrap",sx:{borderColor:"border.default",color:"fg.default",cursor:"pointer","&:hover:not(:disabled)":{borderColor:"accent.fg",color:"accent.fg"},"&:disabled":{opacity:.5,cursor:"default"}},children:t.jsx(vs,{title:e.title,maxWidth:"100%",sx:{minWidth:0},children:e.title})},e.title))}):null,mn=h?t.jsx(f,{flex:"0 0 auto",px:3,py:2,borderTop:"1px solid",borderColor:"border.default",bg:"canvas.subtle",fontSize:1,maxHeight:"40%",overflowY:"auto",children:h}):null;return t.jsxs(f,{ref:me,sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",position:"relative",...$?{bg:"canvas.default"}:null,...$&&!gt.current?{position:"fixed",top:bt,right:0,bottom:0,left:0,height:"auto",zIndex:1e3}:null},children:[ie?t.jsx(ie.Component,{workspace:n,editors:un,hasEditor:!!E,transcript:fn,prompt:Ve?null:it,chips:Ve?null:pn,picker:dn,transient:mn}):t.jsxs(t.Fragment,{children:[Ee&&!Ve?t.jsxs(f,{flex:"0 0 auto",borderBottom:"1px solid",borderColor:"border.default",children:[it,pn]}):null,dn,t.jsxs(f,{flex:"1 1 auto",minHeight:0,display:"flex",position:"relative",children:[un,fn]}),mn,ln||Ve||Ee?null:it]}),wt?t.jsx(f,{position:"absolute",inset:0,zIndex:5,bg:"canvas.default",display:"flex",flexDirection:"column",minHeight:0,children:t.jsx(zs,{agentName:v?.name??j?.name,sandboxStillRuns:g,temporary:Gt,onSignedIn:()=>ys.getState().clear()})}):null]})}function ia({surfaces:n,active:s,onChange:c,workspace:a}){const d=[...n].sort((h,x)=>(h.order??100)-(x.order??100));return t.jsxs(f,{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",children:[t.jsx(W,{sx:{fontSize:0,color:"fg.muted"},children:"Beside the chat"}),t.jsxs($t,{"aria-label":"Editor beside the chat",size:"small",children:[t.jsx($t.Button,{selected:s===X,onClick:()=>c(X),children:"Chat"}),d.map(h=>{const x=De(h,a),C=x?void 0:h.unavailableReason?.(a)??"Not available right now";return t.jsx($t.Button,{selected:s===h.surfaceId,"aria-disabled":!x,title:C??h.title,leadingIcon:h.icon,onClick:()=>{x&&c(h.surfaceId)},children:h.title},h.surfaceId)})]})]})}function Ot({children:n}){return t.jsx(f,{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"fg.muted",fontSize:1,px:3,textAlign:"center",children:n})}export{da as default};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A message of an application's code that changed after it was sent
|
|
3
|
-
* (LOOP P-15).
|
|
4
|
-
*
|
|
5
|
-
* The session API says a message's author, or that it was taken away, with a
|
|
6
|
-
* `CUSTOM` event named `loop.message` — `{id, author}` or `{id, removed: true}`
|
|
7
|
-
* — which the AG-UI adapter hands on as an `activity`. A message whose text
|
|
8
|
-
* changed needs nothing here: it is written again under its id, and the chat
|
|
9
|
-
* draws it in place.
|
|
10
|
-
*/
|
|
11
|
-
import type { MessageSpeaker } from '../../types/messages';
|
|
12
|
-
/** The `CUSTOM` event's name. */
|
|
13
|
-
export declare const LOOP_MESSAGE = "loop.message";
|
|
14
|
-
/** What changed about a message already in the conversation. */
|
|
15
|
-
export type LoopMessageChange = {
|
|
16
|
-
id: string;
|
|
17
|
-
removed: true;
|
|
18
|
-
} | {
|
|
19
|
-
id: string;
|
|
20
|
-
author: string;
|
|
21
|
-
};
|
|
22
|
-
/** The change an activity says, or `null` when it says none. */
|
|
23
|
-
export declare function loopMessageChange(activity: {
|
|
24
|
-
type: string;
|
|
25
|
-
data: unknown;
|
|
26
|
-
} | undefined): LoopMessageChange | null;
|
|
27
|
-
/** Who a message is by, as the chat draws a named voice. */
|
|
28
|
-
export declare function speakerOf(author: string): MessageSpeaker;
|
|
29
|
-
/**
|
|
30
|
-
* The conversation with the change made: the message taken away, or given its
|
|
31
|
-
* author. Items that are not that message — tool calls among them — are left
|
|
32
|
-
* as they are.
|
|
33
|
-
*/
|
|
34
|
-
export declare function withLoopMessage<T extends {
|
|
35
|
-
id?: string;
|
|
36
|
-
speaker?: MessageSpeaker;
|
|
37
|
-
}>(items: T[], change: LoopMessageChange): T[];
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
/** The `CUSTOM` event's name. */
|
|
6
|
-
export const LOOP_MESSAGE = 'loop.message';
|
|
7
|
-
/** The change an activity says, or `null` when it says none. */
|
|
8
|
-
export function loopMessageChange(activity) {
|
|
9
|
-
if (!activity || activity.type !== LOOP_MESSAGE)
|
|
10
|
-
return null;
|
|
11
|
-
const data = activity.data;
|
|
12
|
-
if (!data || typeof data.id !== 'string' || !data.id)
|
|
13
|
-
return null;
|
|
14
|
-
if (data.removed === true)
|
|
15
|
-
return { id: data.id, removed: true };
|
|
16
|
-
if (typeof data.author === 'string' && data.author.trim()) {
|
|
17
|
-
return { id: data.id, author: data.author.trim() };
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
/** Who a message is by, as the chat draws a named voice. */
|
|
22
|
-
export function speakerOf(author) {
|
|
23
|
-
return { id: `author:${author}`, name: author };
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The conversation with the change made: the message taken away, or given its
|
|
27
|
-
* author. Items that are not that message — tool calls among them — are left
|
|
28
|
-
* as they are.
|
|
29
|
-
*/
|
|
30
|
-
export function withLoopMessage(items, change) {
|
|
31
|
-
if ('removed' in change) {
|
|
32
|
-
return items.filter(item => item.id !== change.id);
|
|
33
|
-
}
|
|
34
|
-
return items.map(item => item.id === change.id
|
|
35
|
-
? { ...item, speaker: speakerOf(change.author) }
|
|
36
|
-
: item);
|
|
37
|
-
}
|