@openbkn/workshop 0.2.2-rc.5 → 0.2.2-rc.6
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 +79 -8
- package/component.d.ts +10 -0
- package/dist/ActionConfirm-DJ91X3ml.js +236 -0
- package/dist/ActionFailure-ZgPt_3B-.js +37 -0
- package/dist/AgentChat-CRYai8ge.js +1062 -0
- package/dist/AppFormModal-D73ucaHK.js +4282 -0
- package/dist/AppListPage-D87piiOw.js +1364 -0
- package/dist/AskDrawer-BUMYsRnt.js +38 -0
- package/dist/ComputedView-CgYrDbx1.js +3221 -0
- package/dist/ConclusionApply-sjGfoEBY.js +153 -0
- package/dist/CypherEditor-lus6FA5L.js +485 -0
- package/dist/LandingList-6JI6864C.js +230 -0
- package/dist/MenuUnfoldOutlined-Cdg24l2h.js +27 -0
- package/dist/ModelTrial-ClHFGTpQ.js +359 -0
- package/dist/PageRenderer-DBd_g6mN.js +85480 -0
- package/dist/README-DjRyTQSR.js +76 -0
- package/dist/ScenarioApply-DtW_hh47.js +590 -0
- package/dist/SimulateForm-C-i08Jjd.js +153 -0
- package/dist/Subgraph-CnrkH9AN.js +32586 -0
- package/dist/WorkshopLabPage-DiVXQL9e.js +11364 -0
- package/dist/WorkshopRunPage-6hjRUf64.js +253 -0
- package/dist/abnfDiagram-WEYOIA3C-beRNhN3c.js +87 -0
- package/dist/action-type-tool.service-B2B74fKC.js +1060 -0
- package/dist/actionButton-DA5CNEzx.js +94 -0
- package/dist/actionButton.en-US-qjeqA7hs.js +94 -0
- package/dist/agentChat-EoDznd58.js +116 -0
- package/dist/agentChat.en-US-B6-pFd9Y.js +116 -0
- package/dist/alertList-DqditwM8.js +84 -0
- package/dist/alertList.en-US-BAXAgltP.js +84 -0
- package/dist/architectureDiagram-ZHVYKT53-DY2l1qxx.js +4779 -0
- package/dist/asOfSlider-QPvHWUMV.js +83 -0
- package/dist/asOfSlider.en-US-BI4jVfSn.js +83 -0
- package/dist/bkn-agent-execution.service-DVh-SHyl.js +205 -0
- package/dist/blockDiagram-RJAE7QA3-DR0mjN2h.js +1435 -0
- package/dist/c4Diagram-XDPPPE54-DH5zsGug.js +1518 -0
- package/dist/channel-B034hcOF.js +5 -0
- package/dist/china-C6m7zXIv.js +9 -0
- package/dist/chunk-2E7WHVMD-Ba3svxgx.js +664 -0
- package/dist/chunk-2Q5K7J3B-rT4eU6_y.js +15 -0
- package/dist/chunk-4EMNKR2T-C1kQZYHK.js +262 -0
- package/dist/chunk-55XCU76K-dcpLOktb.js +68 -0
- package/dist/chunk-5VM5RSS4-BdpQuzmO.js +19 -0
- package/dist/chunk-JWPE2WC7-CDBrSjU7.js +8 -0
- package/dist/chunk-VQ5W62QI-BiVKc40w.js +19 -0
- package/dist/chunk-XXDRQBXY-CPYrcdVW.js +8 -0
- package/dist/chunk-ZCHMQSOR-BG8OLpvb.js +451 -0
- package/dist/classDiagram-v2-4MYWR3UA-DqbpQpwI.js +1564 -0
- package/dist/component.d-DFoMKuUv.js +179 -0
- package/dist/cose-bilkent-JH36ORCC-CdXk4sPf.js +2609 -0
- package/dist/customComponents-DasaZ6pq.js +4 -0
- package/dist/customComponents.en-US-CkabuCXg.js +79 -0
- package/dist/customParseFormat-C0uLEpdq.js +182 -0
- package/dist/cynefin-EF2NZ3EQ-D7MVnMHu.js +21746 -0
- package/dist/cynefinDiagram-WF24UDRP-BYT_KpDL.js +299 -0
- package/dist/cytoscape.esm-BCV9V6aO.js +18760 -0
- package/dist/d3-scale-DA8IHmf0.js +1841 -0
- package/dist/dagre-NK4GIZVX-l-ghPdM8.js +2154 -0
- package/dist/dateRange-BbkLMg8L.js +79 -0
- package/dist/dateRange.en-US-CV12Q02G.js +79 -0
- package/dist/dayjs.min-DZ-YV8Mv.js +284 -0
- package/dist/diagram-CBK3MWTC-Bt3HiwvA.js +542 -0
- package/dist/diagram-I5XIIV2D-DcbqfBjx.js +150 -0
- package/dist/diagram-ODIL2UCW-9PC1n3n5.js +346 -0
- package/dist/diagram-PFBEJUXE-DGhr2kc7.js +478 -0
- package/dist/diagram-RJA3I4VV-DwzpOjZ_.js +219 -0
- package/dist/diagram-TYUNFSNR-B3Bd3TDU.js +2583 -0
- package/dist/dropdownFilter-DOi_8-ZT.js +76 -0
- package/dist/dropdownFilter.en-US-BiXpvXtF.js +76 -0
- package/dist/ebnfDiagram-V4P3TTPT-E5NN2oKc.js +109 -0
- package/dist/elk-QONTBCTQ-dFjcujl_.js +49170 -0
- package/dist/erDiagram-KYQIGQAA-BMrasBzB.js +1061 -0
- package/dist/eventList-CnsAwfDS.js +115 -0
- package/dist/eventList.en-US-Cof3rCLq.js +115 -0
- package/dist/eventReport-XS-HegnH.js +76 -0
- package/dist/eventReport.en-US-DTx4vzWT.js +76 -0
- package/dist/flowDiagram-IUGLLWBU-BGIBH0q0.js +1769 -0
- package/dist/ganttChart-DEeSvTJA.js +77 -0
- package/dist/ganttChart.en-US-SwRKrnoD.js +77 -0
- package/dist/ganttDiagram-R7GPNTJY-C0tb1Lpp.js +1741 -0
- package/dist/generateCypher-Ch9_lQa6.js +399 -0
- package/dist/gitGraphDiagram-PDYL7XHY-DBqcOa-c.js +815 -0
- package/dist/graph-CKJmgLki.js +1541 -0
- package/dist/index-BA-GzCXt.js +441 -0
- package/dist/infoDiagram-MVDRKAX5-Bwuki4JA.js +24 -0
- package/dist/ishikawaDiagram-HPEHV2GE-Dz4d6ygx.js +622 -0
- package/dist/journeyDiagram-BOSHW7O7-C99m34Bb.js +834 -0
- package/dist/kanban-definition-FNSA4HC5-mdqjODsT.js +724 -0
- package/dist/katex-BsrBVQKd.js +11314 -0
- package/dist/manifest-BjV1PJ6u.js +41 -0
- package/dist/mermaid.core-yQghUlIz.js +17642 -0
- package/dist/metricCards-CSb-_cT2.js +104 -0
- package/dist/metricCards.en-US-BLLhRsQU.js +104 -0
- package/dist/mindmap-definition-6OY57UG3-BZhO2wX4.js +834 -0
- package/dist/modelTrial-Bvb-RhGt.js +137 -0
- package/dist/modelTrial.en-US-DYcuor-G.js +137 -0
- package/dist/models-DekiCOuZ.js +6 -0
- package/dist/object-metric-numeric-vs3BeDkH.js +42 -0
- package/dist/object-metric.service-flZgBMRX.js +233 -0
- package/dist/objectDetail-SQUbp4Py.js +117 -0
- package/dist/objectDetail.en-US-DW3mlONM.js +117 -0
- package/dist/objectList-D99wPtJH.js +97 -0
- package/dist/objectList.en-US-PBBNyVLW.js +97 -0
- package/dist/objectTable-0jsFFMN3.js +127 -0
- package/dist/objectTable.en-US-yWEs8qc_.js +127 -0
- package/dist/pegDiagram-ECIUJNBX-BDa5RfZt.js +95 -0
- package/dist/pieDiagram-GNMPY74T-DNVtzXPv.js +165 -0
- package/dist/pivotTable-CHmQw18-.js +102 -0
- package/dist/pivotTable.en-US-B4uv4P08.js +102 -0
- package/dist/prompt-DYrjlEFr.js +373 -0
- package/dist/quadrantDiagram-D57K4MC3-vK0f2OvQ.js +1023 -0
- package/dist/railroadDiagram-Y72NRBL7-j6ZrTmRp.js +77 -0
- package/dist/regionMap-Cme-JyV_.js +128 -0
- package/dist/regionMap.en-US-Bwr2_p32.js +128 -0
- package/dist/requirementDiagram-EQYSW5RA-DgfEyljA.js +886 -0
- package/dist/sankeyDiagram-SY24JHO5-CImx-IX0.js +1160 -0
- package/dist/scenarioBar-BV43p7n-.js +122 -0
- package/dist/scenarioBar.en-US-5KqMQ2Bg.js +122 -0
- package/dist/scheduleGantt-CTYO-zYP.js +180 -0
- package/dist/scheduleGantt.en-US-hE7mvVUW.js +180 -0
- package/dist/searchBox-Ca7w0f_6.js +67 -0
- package/dist/searchBox.en-US-ArS_XBvB.js +67 -0
- package/dist/segmentedFilter-MhjVcWo0.js +80 -0
- package/dist/segmentedFilter.en-US-BxNrQO5T.js +80 -0
- package/dist/sequenceDiagram-BLEHNHQU-nWmjd1ci.js +2969 -0
- package/dist/sizeCapture-INFHLROL-D3jlbt7h.js +46 -0
- package/dist/stageChain-BxBafwjD.js +74 -0
- package/dist/stageChain.en-US-CP0G27n8.js +74 -0
- package/dist/stateDiagram-v2-A6IESKWZ-DG1ZetEu.js +1514 -0
- package/dist/subgraph-7n4SwliR.js +71 -0
- package/dist/subgraph.en-US-BNvY18IW.js +71 -0
- package/dist/swimlanes-B3ENRKFQ-cCmJE8AU.js +4991 -0
- package/dist/swimlanesDiagram-AYQRV4AK-CtuhyguU.js +14 -0
- package/dist/taskInbox-DGWYeI2b.js +118 -0
- package/dist/taskInbox.en-US-B-OzDmVl.js +118 -0
- package/dist/text-BqSVQKS6.js +78 -0
- package/dist/text.en-US-BhAxy_LE.js +78 -0
- package/dist/timeline-definition-JXYKGLGB-Cc-INsOv.js +1057 -0
- package/dist/trendChart-BjEeRS5_.js +135 -0
- package/dist/trendChart.en-US-BBGqWUKM.js +135 -0
- package/dist/useLabData-Df-jEHKs.js +20470 -0
- package/dist/usecaseDiagram-WPOLBNNX-r8wVjopm.js +7920 -0
- package/dist/vennDiagram-Q3Y3IDCW-BZiOcgrj.js +1579 -0
- package/dist/wardleyDiagram-IVAIDKWA-16jd07C_.js +675 -0
- package/dist/workshop-app-DnHNjBqy.js +86038 -0
- package/dist/workshop-app.css +1 -0
- package/dist/workshop-app.js +4 -0
- package/dist/world-Djau1JyJ.js +9 -0
- package/dist/xychartDiagram-4URNHDU4-C8DwWQNh.js +1460 -0
- package/dist-cli/workshop.js +340 -217
- package/example/host.js +109 -0
- package/example/index.html +93 -0
- package/example/server.mjs +237 -0
- package/index.d.ts +48 -0
- package/lib/validate.js +47 -1
- package/package.json +17 -5
- package/runtime/frame-runtime.js +13 -1
- package/workshop-component.js +32 -12
- package/workshop.js +2 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const n = `# 基准日期(asOfSlider)
|
|
2
|
+
|
|
3
|
+
拖动滑块选一个日期,整页按这一天计算。用来回答“截至某天是什么样”“上个月底有多少项已超期”这类问题。
|
|
4
|
+
|
|
5
|
+
## 适用与不适用
|
|
6
|
+
|
|
7
|
+
- 适用:数据源配了进度,或有读取基准日期的计算列,需要看过去(或未来)某一天的状态。例如订单在某天是否已签约、截至某天已超期多少天。
|
|
8
|
+
- 不适用:
|
|
9
|
+
- 只想看某段时间内发生的对象:用日期区间(\`dateRange\`)。
|
|
10
|
+
- 只想按某个字段的取值筛选:用分段筛选(\`segmentedFilter\`)或下拉筛选(\`dropdownFilter\`)。
|
|
11
|
+
- 想对比“采用前后”:用方案(\`scenarioBar\`)。
|
|
12
|
+
|
|
13
|
+
## 本体契约
|
|
14
|
+
|
|
15
|
+
| 角色 | 对象类要求 | 必要的属性 | 关系 | 必填 |
|
|
16
|
+
| --- | --- | --- | --- | --- |
|
|
17
|
+
| 范围对象 | 决定滑块能拖多远的对象,通常是页面的主数据源 | 一个日期属性(默认取进度第一步的日期) | 无 | 是:需要一个数据源;日期属性不配、进度也没有日期时,滑块只覆盖最近一年 |
|
|
18
|
+
|
|
19
|
+
## 组件内置的判断
|
|
20
|
+
|
|
21
|
+
与行业无关,组件自己处理:
|
|
22
|
+
|
|
23
|
+
- 滑块范围:起点是“范围日期属性”的最早值,终点是今天;数据源进度各步骤和到期日里更晚的日期、页面基准日期变量的默认值晚于今天时,终点顺延到这些日期,页面可以往后看。
|
|
24
|
+
- 没有可用的起点时,范围为终点往前一年。
|
|
25
|
+
- 步长按天、周、月(月按 30 天)。
|
|
26
|
+
- 拖动时滑块自己显示当前日期,页面每 250 毫秒左右才取一次,松手时立即取,避免整页反复重算。
|
|
27
|
+
- 日期不是今天时,卡片右上显示“回到今天”。
|
|
28
|
+
- 页面没有设置基准日期时,全页按今天计算。
|
|
29
|
+
|
|
30
|
+
## 扩展点
|
|
31
|
+
|
|
32
|
+
无。组件只写基准日期,不调用工具。行业口径(例如“超期”怎么算)写在数据源的进度与计算列里,由它们读取基准日期。
|
|
33
|
+
|
|
34
|
+
## 交互与联动
|
|
35
|
+
|
|
36
|
+
- **写入**:拖动或松手后写入配置的基准日期变量。页面上同一时间只有一个基准日期变量生效。
|
|
37
|
+
- **读取**:不跟随任何筛选。
|
|
38
|
+
- **谁会跟着变**:设置了进度或使用基准日期的计算列的数据源,以及用它们的组件(对象表、指标卡组、图表、告警等)自动按该日期重算,不需要在组件里勾选。指标卡组选“截至基准日期”时,同比环比也随它移动。
|
|
39
|
+
- 范围按已读入的数据计算;数据源读取有行数上限(对象类数据源 5000 行;Cypher 数据源 10000 行,查询没写 LIMIT 时 1000 行),超过时范围只覆盖读到的部分。
|
|
40
|
+
|
|
41
|
+
## 场景配方
|
|
42
|
+
|
|
43
|
+
### 合同与回款:截至某天的超期情况
|
|
44
|
+
|
|
45
|
+
| 角色 | 对应 |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| 范围对象 | 合同(范围日期属性:签约日期) |
|
|
48
|
+
|
|
49
|
+
**知识网络中要有:** 合同的签约日期、约定回款日期。“是否超期”写成数据源进度或计算列(回款日期早于基准日期且未回款),不要写进滑块。
|
|
50
|
+
|
|
51
|
+
**检查项:** 拖到合同签约之前,该合同不再出现;拖到约定回款日期之后,该合同显示为超期;点“回到今天”恢复。
|
|
52
|
+
|
|
53
|
+
### 生产计划:回看某天的在制情况
|
|
54
|
+
|
|
55
|
+
| 角色 | 对应 |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| 范围对象 | 生产工单(范围日期属性:计划开始) |
|
|
58
|
+
|
|
59
|
+
**知识网络中要有:** 工单的开始、结束日期与状态。在制与否由进度判断。
|
|
60
|
+
|
|
61
|
+
**检查项:** 拖动后,指标卡组中“在制”数量随日期变化;表格的状态列同步变化。
|
|
62
|
+
|
|
63
|
+
## 给 AI 的指引
|
|
64
|
+
|
|
65
|
+
1. 先问用户:回看到哪一天为止?是否需要往未来看?数据里哪个日期代表“对象出现”?
|
|
66
|
+
2. 页面里要有一个类型为基准日期的变量,组件的“写入”选它;没有就先建,不要借用别的筛选变量。
|
|
67
|
+
3. “滑块范围取自”选页面的主数据源;“范围日期属性”选对象出现的那天,不选时取进度第一步的日期。
|
|
68
|
+
4. 常见错误:
|
|
69
|
+
- 数据源既没配进度,也没有读取基准日期的计算列:滑块拖了页面毫无变化。先配进度或计算列。
|
|
70
|
+
- 范围日期属性选了字符串或数字字段:只能选日期类型。
|
|
71
|
+
- 把基准日期当筛选,去别的组件的“跟随的筛选”里找它:基准日期不属于筛选,自动生效。
|
|
72
|
+
- 一个页面放多个基准日期滑块:只有第一个基准日期变量生效。
|
|
73
|
+
|
|
74
|
+
## 限制
|
|
75
|
+
|
|
76
|
+
- 范围日期属性必须是日期类型。
|
|
77
|
+
- 步长只有天、周、月三种;月固定按 30 天。
|
|
78
|
+
- 一个页面一个基准日期变量。
|
|
79
|
+
- 范围依据已读入的数据,对象类数据源最多读 5000 行,Cypher 数据源最多 10000 行(查询没写 LIMIT 时 1000 行)。
|
|
80
|
+
`;
|
|
81
|
+
export {
|
|
82
|
+
n as default
|
|
83
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const e = `# Base date (asOfSlider)
|
|
2
|
+
|
|
3
|
+
Drag a slider to pick a date, and the whole page is computed as of that day. Use it to answer "what did it look like on a given day" or "how many items were overdue at the end of last month".
|
|
4
|
+
|
|
5
|
+
## When to use it and when not
|
|
6
|
+
|
|
7
|
+
- Use it when the data source has progress set up, or has computed columns that read the base date, and you need to see the state on a past (or future) day. For example: whether an order was signed on a given day, or how many days overdue it was as of that day.
|
|
8
|
+
- Do not use it:
|
|
9
|
+
- To see only objects that occurred within a period: use the date range (\`dateRange\`).
|
|
10
|
+
- To filter by the value of one field: use the segmented filter (\`segmentedFilter\`) or the dropdown filter (\`dropdownFilter\`).
|
|
11
|
+
- To compare before and after applying a change: use the scenario bar (\`scenarioBar\`).
|
|
12
|
+
|
|
13
|
+
## Ontology contract
|
|
14
|
+
|
|
15
|
+
| Role | Object type requirement | Required properties | Relations | Required |
|
|
16
|
+
| --- | --- | --- | --- | --- |
|
|
17
|
+
| Range object | The object that decides how far the slider goes, usually the page's main data source | One date property (by default the date of the first progress step) | None | Yes: a data source is needed; with no date property and no dated progress step, the slider covers only the last year |
|
|
18
|
+
|
|
19
|
+
## Built-in checks
|
|
20
|
+
|
|
21
|
+
The component handles these itself, whatever the industry:
|
|
22
|
+
|
|
23
|
+
- Slider range: it starts at the earliest value of the range date property and ends today. The end moves later when the source's progress steps or due date have later dates, or when the page's base date variable has a default later than today, so the page can look ahead.
|
|
24
|
+
- With no usable start, the range is one year back from the end.
|
|
25
|
+
- Steps are day, week or month (a month is 30 days).
|
|
26
|
+
- While dragging, the slider shows its own date; the page takes it about every 250 ms and at once when released, so the whole page does not recompute over and over.
|
|
27
|
+
- When the date is not today, a "back to today" button shows at the top right of the card.
|
|
28
|
+
- When the page sets no base date, everything is computed as of today.
|
|
29
|
+
|
|
30
|
+
## Extension points
|
|
31
|
+
|
|
32
|
+
None. The component only writes the base date and calls no tool. Industry rules (for example, what counts as overdue) go in the data source's progress and computed columns, which read the base date.
|
|
33
|
+
|
|
34
|
+
## Interaction and links
|
|
35
|
+
|
|
36
|
+
- **Writes**: the configured base date variable, while dragging and on release. Only one base date variable is in effect on a page.
|
|
37
|
+
- **Reads**: it follows no filter.
|
|
38
|
+
- **What changes with it**: data sources with progress, or with computed columns that read the base date, and the components that use them (object table, metric cards, charts, alerts and so on), are recomputed as of that date automatically; nothing has to be ticked in the components. With metric cards set to "as of the base date", year-over-year and period-over-period comparisons move with it.
|
|
39
|
+
- The range is computed from the rows already read; an object type data source reads at most 5000 rows and a Cypher data source 10,000 (1,000 when its query sets no LIMIT), so beyond that the range covers only what was read.
|
|
40
|
+
|
|
41
|
+
## Recipes
|
|
42
|
+
|
|
43
|
+
### Contracts and collections: overdue as of a given day
|
|
44
|
+
|
|
45
|
+
| Role | Maps to |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| Range object | Contract (range date property: signing date) |
|
|
48
|
+
|
|
49
|
+
**Needed in the knowledge network:** the contract's signing date and agreed collection date. "Overdue" is written as the source's progress or a computed column (collection date before the base date and not collected), not in the slider.
|
|
50
|
+
|
|
51
|
+
**Checks:** drag to before a contract was signed and it disappears; drag to after its collection date and it shows as overdue; "back to today" restores the page.
|
|
52
|
+
|
|
53
|
+
### Production plan: looking back at work in progress
|
|
54
|
+
|
|
55
|
+
| Role | Maps to |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| Range object | Production work order (range date property: planned start) |
|
|
58
|
+
|
|
59
|
+
**Needed in the knowledge network:** the work order's start and end dates and status. Whether it is in progress is decided by progress.
|
|
60
|
+
|
|
61
|
+
**Checks:** after dragging, the "in progress" count in the metric cards changes with the date, and the status column of the table changes with it.
|
|
62
|
+
|
|
63
|
+
## Guidance for AI
|
|
64
|
+
|
|
65
|
+
1. Ask the user first: how far back should it go? Should it look ahead? Which date means that the object has appeared?
|
|
66
|
+
2. The page needs a variable of the base date kind, and the component's "write" setting points to it. If there is none, create one; do not reuse another filter variable.
|
|
67
|
+
3. Choose the page's main data source for "slider range taken from". For "range date property" choose the date on which the object appears; if it is left empty, the first progress step's date is used.
|
|
68
|
+
4. Common mistakes:
|
|
69
|
+
- The data source has neither progress nor computed columns that read the base date: dragging changes nothing on the page. Set up progress or the column first.
|
|
70
|
+
- A text or number field as the range date property: only date fields are allowed.
|
|
71
|
+
- Looking for the base date among other components' followed filters: the base date is not a filter and takes effect automatically.
|
|
72
|
+
- Several base date sliders on one page: only the first base date variable is in effect.
|
|
73
|
+
|
|
74
|
+
## Limits
|
|
75
|
+
|
|
76
|
+
- The range date property must be a date field.
|
|
77
|
+
- Steps are day, week and month only; a month is fixed at 30 days.
|
|
78
|
+
- One base date variable per page.
|
|
79
|
+
- The range depends on the rows already read; an object type data source reads at most 5000 rows and a Cypher data source 10,000 (1,000 when its query sets no LIMIT).
|
|
80
|
+
`;
|
|
81
|
+
export {
|
|
82
|
+
e as default
|
|
83
|
+
};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { s as d, m as f } from "./workshop-app-DnHNjBqy.js";
|
|
2
|
+
const m = "/api/bkn-agent/v1/executions", _ = "studio_smart_qa", N = "eval_assistant";
|
|
3
|
+
class h extends Error {
|
|
4
|
+
constructor(o, a, t, n) {
|
|
5
|
+
super(o), this.status = a, this.code = t, this.detail = n, this.name = "BknAgentExecutionError";
|
|
6
|
+
}
|
|
7
|
+
status;
|
|
8
|
+
code;
|
|
9
|
+
detail;
|
|
10
|
+
}
|
|
11
|
+
function i(e) {
|
|
12
|
+
return e && typeof e == "object" && !Array.isArray(e) ? e : null;
|
|
13
|
+
}
|
|
14
|
+
function r(e) {
|
|
15
|
+
return typeof e == "string" ? e : void 0;
|
|
16
|
+
}
|
|
17
|
+
function A(e) {
|
|
18
|
+
let o = "message";
|
|
19
|
+
const a = [];
|
|
20
|
+
for (const n of e.split(`
|
|
21
|
+
`))
|
|
22
|
+
n.startsWith("event:") ? o = n.slice(6).trim() : n.startsWith("data:") && a.push(n.slice(5).replace(/^ /, ""));
|
|
23
|
+
if (a.length === 0) return null;
|
|
24
|
+
let t;
|
|
25
|
+
try {
|
|
26
|
+
t = i(JSON.parse(a.join(`
|
|
27
|
+
`)));
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
if (!t) return null;
|
|
32
|
+
switch (o) {
|
|
33
|
+
case "meta":
|
|
34
|
+
return { type: "meta", runId: r(t.run_id) ?? "", threadId: r(t.thread_id) ?? "" };
|
|
35
|
+
case "token":
|
|
36
|
+
return typeof t.content == "string" ? { type: "token", content: t.content } : null;
|
|
37
|
+
case "reasoning":
|
|
38
|
+
return typeof t.content == "string" ? { type: "reasoning", content: t.content } : null;
|
|
39
|
+
case "tool_started":
|
|
40
|
+
return {
|
|
41
|
+
type: "tool_started",
|
|
42
|
+
id: r(t.tool_call_id) ?? "",
|
|
43
|
+
name: r(t.name) ?? "",
|
|
44
|
+
input: t.input
|
|
45
|
+
};
|
|
46
|
+
case "tool_finished":
|
|
47
|
+
return {
|
|
48
|
+
type: "tool_finished",
|
|
49
|
+
id: r(t.tool_call_id) ?? "",
|
|
50
|
+
name: r(t.name) ?? "",
|
|
51
|
+
status: t.status === "failed" ? "failed" : "succeeded",
|
|
52
|
+
output: t.output,
|
|
53
|
+
error: t.error,
|
|
54
|
+
errorKind: t.error_kind === "unavailable" ? "unavailable" : t.status === "failed" ? "error" : void 0,
|
|
55
|
+
durationMs: typeof t.duration_ms == "number" ? t.duration_ms : void 0,
|
|
56
|
+
...i(t.progress) ? { progress: i(t.progress) ?? void 0 } : {}
|
|
57
|
+
};
|
|
58
|
+
case "usage":
|
|
59
|
+
return {
|
|
60
|
+
type: "usage",
|
|
61
|
+
usage: t.available ? i(t.usage) : null
|
|
62
|
+
};
|
|
63
|
+
case "result": {
|
|
64
|
+
const n = i(t.content) ?? {};
|
|
65
|
+
return { type: "result", answer: r(n.answer) ?? "", content: n };
|
|
66
|
+
}
|
|
67
|
+
case "terminal": {
|
|
68
|
+
const n = t.status, s = i(t.error), u = i(s?.upstream);
|
|
69
|
+
return {
|
|
70
|
+
type: "terminal",
|
|
71
|
+
status: n === "succeeded" || n === "cancelled" ? n : "failed",
|
|
72
|
+
code: r(s?.code),
|
|
73
|
+
detail: r(s?.detail),
|
|
74
|
+
upstream: u ? { code: r(u.code), message: r(u.message) } : void 0,
|
|
75
|
+
runId: r(t.run_id)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
default:
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function k(e) {
|
|
83
|
+
const o = await e.text().catch(() => "");
|
|
84
|
+
let a = null;
|
|
85
|
+
try {
|
|
86
|
+
a = i(JSON.parse(o));
|
|
87
|
+
} catch {
|
|
88
|
+
}
|
|
89
|
+
const t = r(a?.code), n = r(a?.description) ?? r(a?.message) ?? (e.statusText || `HTTP ${e.status}`);
|
|
90
|
+
return new h(n, e.status, t, o || void 0);
|
|
91
|
+
}
|
|
92
|
+
function T() {
|
|
93
|
+
return typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Array.from(
|
|
94
|
+
crypto.getRandomValues(new Uint8Array(16)),
|
|
95
|
+
(e) => e.toString(16).padStart(2, "0")
|
|
96
|
+
).join("");
|
|
97
|
+
}
|
|
98
|
+
async function v(e) {
|
|
99
|
+
const a = await f(e.tokenProvider)(`${e.base}${m}`, {
|
|
100
|
+
method: "POST",
|
|
101
|
+
headers: { Accept: "text/event-stream", "Content-Type": "application/json" },
|
|
102
|
+
body: JSON.stringify({
|
|
103
|
+
agent_id: e.agentId ?? _,
|
|
104
|
+
message: e.message,
|
|
105
|
+
client_request_id: e.clientRequestId,
|
|
106
|
+
...e.threadId ? { thread_id: e.threadId } : {},
|
|
107
|
+
...e.modelId ? { model_id: e.modelId } : {},
|
|
108
|
+
context: { ...e.context, kn_id: e.knId }
|
|
109
|
+
}),
|
|
110
|
+
signal: e.signal
|
|
111
|
+
});
|
|
112
|
+
if (!a.ok) throw await k(a);
|
|
113
|
+
if (!a.body) return null;
|
|
114
|
+
const t = a.body.getReader(), n = new TextDecoder();
|
|
115
|
+
let s = "", u = null;
|
|
116
|
+
for (; ; ) {
|
|
117
|
+
const { done: l, value: w } = await t.read();
|
|
118
|
+
s += n.decode(w, { stream: !l }).replace(/\r\n/g, `
|
|
119
|
+
`);
|
|
120
|
+
const g = s.split(`
|
|
121
|
+
|
|
122
|
+
`);
|
|
123
|
+
s = l ? "" : g.pop() ?? "";
|
|
124
|
+
for (const y of g) {
|
|
125
|
+
const c = A(y);
|
|
126
|
+
c && (c.type === "terminal" && (u = c), e.onEvent(c));
|
|
127
|
+
}
|
|
128
|
+
if (l) return u;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async function p({ base: e, tokenProvider: o, runId: a }, t) {
|
|
132
|
+
const n = await f(o)(
|
|
133
|
+
`${e}${m}/${encodeURIComponent(a)}${t}`,
|
|
134
|
+
{ method: t ? "POST" : "GET", headers: { Accept: "application/json" } }
|
|
135
|
+
);
|
|
136
|
+
if (!n.ok) throw await k(n);
|
|
137
|
+
return await n.json();
|
|
138
|
+
}
|
|
139
|
+
function I(e) {
|
|
140
|
+
return p(e, "");
|
|
141
|
+
}
|
|
142
|
+
function B(e) {
|
|
143
|
+
return p(e, "/cancel");
|
|
144
|
+
}
|
|
145
|
+
const E = {
|
|
146
|
+
"BknAgent.Chat.Timeout": "knowledgeNetwork.agentChat.execution.errors.timeout",
|
|
147
|
+
"BknAgent.Model.Unavailable": "knowledgeNetwork.agentChat.execution.errors.modelUnavailable",
|
|
148
|
+
"BknAgent.Model.Rejected": "knowledgeNetwork.agentChat.execution.errors.modelRejected",
|
|
149
|
+
"BknAgent.Execution.Unavailable": "knowledgeNetwork.agentChat.execution.errors.unavailable",
|
|
150
|
+
"BknAgent.Execution.Forbidden": "knowledgeNetwork.agentChat.execution.errors.forbidden"
|
|
151
|
+
}, b = /* @__PURE__ */ new Set([
|
|
152
|
+
"BknAgent.Chat.Timeout",
|
|
153
|
+
"BknAgent.Model.Unavailable",
|
|
154
|
+
"BknAgent.Chat.Failed",
|
|
155
|
+
"BknAgent.Execution.Failed",
|
|
156
|
+
"BknAgent.Execution.Unavailable"
|
|
157
|
+
]);
|
|
158
|
+
function C(e, o = {}) {
|
|
159
|
+
const a = e ? E[e] : void 0, t = a ? d.t(a) : o.detail ?? d.t("knowledgeNetwork.agentChat.execution.errors.failed"), n = o.upstream?.message ? d.t("knowledgeNetwork.agentChat.execution.errors.withCause", {
|
|
160
|
+
message: t,
|
|
161
|
+
cause: o.upstream.message
|
|
162
|
+
}) : t, s = [
|
|
163
|
+
e && `code: ${e}`,
|
|
164
|
+
o.upstream?.code && `upstream: ${o.upstream.code}`,
|
|
165
|
+
o.runId && `run_id: ${o.runId}`
|
|
166
|
+
].filter(Boolean);
|
|
167
|
+
return {
|
|
168
|
+
message: n,
|
|
169
|
+
detail: s.length ? s.join(`
|
|
170
|
+
`) : void 0,
|
|
171
|
+
retryable: !e || b.has(e)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function S(e) {
|
|
175
|
+
return e instanceof h ? e.status === 404 && e.code === "BknAgent.NotFound" ? {
|
|
176
|
+
message: d.t("knowledgeNetwork.agentChat.execution.errors.agentNotReady"),
|
|
177
|
+
detail: e.detail,
|
|
178
|
+
retryable: !1
|
|
179
|
+
} : e.code === "BknAgent.Thread.Busy" ? {
|
|
180
|
+
message: d.t("knowledgeNetwork.agentChat.execution.errors.threadBusy"),
|
|
181
|
+
detail: e.detail,
|
|
182
|
+
retryable: !0
|
|
183
|
+
} : {
|
|
184
|
+
message: e.message,
|
|
185
|
+
detail: e.detail,
|
|
186
|
+
retryable: e.status >= 500 || e.status === 429
|
|
187
|
+
} : {
|
|
188
|
+
message: d.t("knowledgeNetwork.agentChat.execution.errors.network"),
|
|
189
|
+
detail: e instanceof Error ? e.message : String(e),
|
|
190
|
+
retryable: !0
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
export {
|
|
194
|
+
m as BKN_AGENT_EXECUTIONS_PATH,
|
|
195
|
+
h as BknAgentExecutionError,
|
|
196
|
+
N as EVAL_ASSISTANT_AGENT_ID,
|
|
197
|
+
_ as SMART_QA_AGENT_ID,
|
|
198
|
+
B as cancelExecution,
|
|
199
|
+
S as executionRequestError,
|
|
200
|
+
I as getExecution,
|
|
201
|
+
T as newClientRequestId,
|
|
202
|
+
A as parseExecutionFrame,
|
|
203
|
+
v as startExecution,
|
|
204
|
+
C as terminalError
|
|
205
|
+
};
|