@engenty/wizards-runtime 0.17.0 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/apps/runtime/dist/app.js +2 -0
  2. package/apps/runtime/dist/broker/account.js +20 -1
  3. package/apps/runtime/dist/broker/call.js +116 -20
  4. package/apps/runtime/dist/broker/host.js +8 -2
  5. package/apps/runtime/dist/broker/index.js +3 -2
  6. package/apps/runtime/dist/broker/log.js +149 -14
  7. package/apps/runtime/dist/broker/over.js +38 -0
  8. package/apps/runtime/dist/broker/rights.js +192 -0
  9. package/apps/runtime/dist/broker/rwx.js +295 -51
  10. package/apps/runtime/dist/broker/send.js +25 -12
  11. package/apps/runtime/dist/bundles/discover.js +133 -0
  12. package/apps/runtime/dist/bundles/fetch.js +119 -0
  13. package/apps/runtime/dist/bundles/index.js +621 -0
  14. package/apps/runtime/dist/bundles/read.js +607 -0
  15. package/apps/runtime/dist/connectors/external.js +540 -61
  16. package/apps/runtime/dist/connectors/person-sign-ins.js +1 -0
  17. package/apps/runtime/dist/connectors/reload.js +73 -0
  18. package/apps/runtime/dist/connectors/space-connections.js +73 -6
  19. package/apps/runtime/dist/db/migrations/tenant/0058_mcp_state_across_roles.sql +26 -0
  20. package/apps/runtime/dist/db/migrations/tenant/0059_space_connection_paused.sql +2 -0
  21. package/apps/runtime/dist/db/migrations/tenant/0060_space_bundle.sql +21 -0
  22. package/apps/runtime/dist/db/migrations/tenant/0061_space_connection_limits.sql +2 -0
  23. package/apps/runtime/dist/db/migrations/tenant/meta/0058_snapshot.json +6696 -0
  24. package/apps/runtime/dist/db/migrations/tenant/meta/0059_snapshot.json +6710 -0
  25. package/apps/runtime/dist/db/migrations/tenant/meta/0060_snapshot.json +6857 -0
  26. package/apps/runtime/dist/db/migrations/tenant/meta/0061_snapshot.json +6871 -0
  27. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +28 -0
  28. package/apps/runtime/dist/db/schema.js +81 -3
  29. package/apps/runtime/dist/docs/dev/broker.md +312 -32
  30. package/apps/runtime/dist/docs/dev/skills.md +8 -1
  31. package/apps/runtime/dist/docs/user-guide/capabilities.md +127 -5
  32. package/apps/runtime/dist/docs/user-guide/connectors.md +103 -5
  33. package/apps/runtime/dist/docs/user-guide/protocol.md +15 -4
  34. package/apps/runtime/dist/docs/user-guide/skills.md +11 -1
  35. package/apps/runtime/dist/docs/user-guide/test-and-share.md +1 -1
  36. package/apps/runtime/dist/elements/caller.js +2 -2
  37. package/apps/runtime/dist/engenty/connections-external/build-connector.js +23 -8
  38. package/apps/runtime/dist/engenty/connections-external/import-service.js +18 -9
  39. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +12 -0
  40. package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +1 -0
  41. package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +6 -3
  42. package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +2 -2
  43. package/apps/runtime/dist/engenty/shims/web-ingest.js +64 -0
  44. package/apps/runtime/dist/engine/resources.js +15 -6
  45. package/apps/runtime/dist/engine/runner.js +2 -1
  46. package/apps/runtime/dist/env.js +2 -0
  47. package/apps/runtime/dist/index.js +11 -2
  48. package/apps/runtime/dist/mcp/handler.js +2 -2
  49. package/apps/runtime/dist/mcp/seen.js +71 -51
  50. package/apps/runtime/dist/mcp/tools.js +5 -1
  51. package/apps/runtime/dist/prompts/mcp.md +1 -1
  52. package/apps/runtime/dist/prompts/tools.md +16 -0
  53. package/apps/runtime/dist/routes/broker.js +1 -1
  54. package/apps/runtime/dist/routes/bundles.js +91 -0
  55. package/apps/runtime/dist/routes/connections.js +14 -3
  56. package/apps/runtime/dist/routes/discover.js +1 -0
  57. package/apps/runtime/dist/routes/rules.js +53 -9
  58. package/apps/runtime/dist/routes/studio.js +23 -18
  59. package/apps/runtime/dist/services/cloud.js +2 -0
  60. package/apps/runtime/dist/services/discover.js +9 -3
  61. package/apps/runtime/dist/services/draft-events.js +79 -6
  62. package/apps/runtime/dist/services/files.js +2 -2
  63. package/apps/runtime/dist/services/skills.js +61 -5
  64. package/apps/runtime/dist/services/space-index.js +113 -11
  65. package/apps/runtime/dist/services/synced-spaces.js +5 -1
  66. package/apps/runtime/dist/services/wizards.js +48 -2
  67. package/apps/runtime/dist/sharing/jobs.js +6 -2
  68. package/apps/runtime/dist/sync/records.js +6 -1
  69. package/apps/runtime/dist/texts.js +36 -1
  70. package/apps/runtime/dist/tools/connections.js +8 -0
  71. package/apps/runtime/dist/tools/connector.js +13 -1
  72. package/apps/runtime/dist/tools/index.js +8 -3
  73. package/apps/runtime/dist/tools/skills.js +11 -1
  74. package/apps/web/dist/assets/{AboutDialog-B2Xmxyj4.js → AboutDialog-NzB-GEj_.js} +1 -1
  75. package/apps/web/dist/assets/{BlockEditor-D0HoUSih.js → BlockEditor-HyDf8fOb.js} +1 -1
  76. package/apps/web/dist/assets/Bundle-B0Bhs0By.js +1 -0
  77. package/apps/web/dist/assets/CapabilitiesPage-CQSaMsWK.js +2 -0
  78. package/apps/web/dist/assets/{ChangelogDialog-BIrJbAKi.js → ChangelogDialog-Ngxuqubx.js} +1 -1
  79. package/apps/web/dist/assets/{CodeEditor-DUVcXI5P.js → CodeEditor-C2LBf4pS.js} +1 -1
  80. package/apps/web/dist/assets/EditorPage-Dysvvadu.js +3 -0
  81. package/apps/web/dist/assets/{FlowPreview-BIag8_Be.js → FlowPreview-CGfSaeYu.js} +1 -1
  82. package/apps/web/dist/assets/LangSwitch-B7UQlGh5.js +1 -0
  83. package/apps/web/dist/assets/Marketplace-BkIxd1PW.js +2 -0
  84. package/apps/web/dist/assets/{NewWizardChannels-DI3SQ4iS.js → NewWizardChannels-BWLaVFld.js} +1 -1
  85. package/apps/web/dist/assets/NewWizardPage-BpRd8tDF.js +7 -0
  86. package/apps/web/dist/assets/OnboardingPage-ScEcQcR0.js +1 -0
  87. package/apps/web/dist/assets/PreviewPane-CaC1FYxZ.js +7 -0
  88. package/apps/web/dist/assets/ProtocolSection-CILRCYLD.js +1 -0
  89. package/apps/web/dist/assets/PublicRunner-DHX431Pr.js +1 -0
  90. package/apps/web/dist/assets/{ReadOnly-CWf5x74a.js → ReadOnly-DqS1UDQs.js} +1 -1
  91. package/apps/web/dist/assets/SettingsPage-Dp2-rHXu.js +2 -0
  92. package/apps/web/dist/assets/SetupPage-mzMLQcD5.js +1 -0
  93. package/apps/web/dist/assets/SharePage-CBDgqEH7.js +1 -0
  94. package/apps/web/dist/assets/SkillEditor-Cf6FqkkU.js +1 -0
  95. package/apps/web/dist/assets/{Skills-CN4QE7Kx.js → Skills-DqV5Oqqu.js} +5 -5
  96. package/apps/web/dist/assets/SpacePage-C3SXe2hs.js +2 -0
  97. package/apps/web/dist/assets/{UpdateCheck-QhBI3rlQ.js → UpdateCheck-B51jMIhp.js} +2 -2
  98. package/apps/web/dist/assets/brand-CG35IRgr.js +2 -0
  99. package/apps/web/dist/assets/changelog-DN6sziTl.js +1 -0
  100. package/apps/web/dist/assets/{code-editor-DkPo1C-L.js → code-editor-Bsyy7cuT.js} +2 -2
  101. package/apps/web/dist/assets/{host-D6H6Z9Jp.js → host-DaDyLfqT.js} +16 -16
  102. package/apps/web/dist/assets/i18n-CyrHWeGk.js +55 -0
  103. package/apps/web/dist/assets/index-Db9JthZr.css +1 -0
  104. package/apps/web/dist/assets/index-LjwVRoki.js +10 -0
  105. package/apps/web/dist/assets/minus-BpYkOkYw.js +1 -0
  106. package/apps/web/dist/assets/plug-De3mHDFV.js +1 -0
  107. package/apps/web/dist/assets/{read-aloud-CnFwDSGD.js → read-aloud-DCTouK7J.js} +1 -1
  108. package/apps/web/dist/assets/{runners-0sTPbWzr.js → runners-DtiBHvG7.js} +1 -1
  109. package/apps/web/dist/assets/session-DKGZUy6h.js +1 -0
  110. package/apps/web/dist/assets/{theme-CkNTe-_Z.js → theme-Bcj8TXQr.js} +2 -2
  111. package/apps/web/dist/assets/{ui-DAk_vjrL.js → ui-C6vSmisV.js} +1 -1
  112. package/apps/web/dist/assets/{useMutation-isHfB33W.js → useMutation-B8hJ5Z6N.js} +1 -1
  113. package/apps/web/dist/assets/{viewers-ijNZHJFG.js → viewers-b9FdC42r.js} +2 -2
  114. package/apps/web/dist/assets/{volume-2-BqlBtCIJ.js → volume-2-B1roRk6x.js} +1 -1
  115. package/apps/web/dist/index.html +15 -13
  116. package/apps/web/dist/mcp/flow.html +2 -2
  117. package/node_modules/@engenty/wizards-shared/dist/bundles.d.ts +219 -0
  118. package/node_modules/@engenty/wizards-shared/dist/bundles.js +19 -0
  119. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +105 -4
  120. package/node_modules/@engenty/wizards-shared/dist/connectors.js +6 -0
  121. package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +28 -1
  122. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +8 -0
  123. package/node_modules/@engenty/wizards-shared/dist/run.js +16 -0
  124. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +84 -1
  125. package/node_modules/@engenty/wizards-shared/dist/rwx.js +69 -1
  126. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +20 -3
  127. package/node_modules/@engenty/wizards-shared/dist/skills.js +5 -2
  128. package/package.json +1 -1
  129. package/plugin/.claude-plugin/plugin.json +1 -1
  130. package/plugin/plugin.json +1 -1
  131. package/apps/web/dist/assets/CapabilitiesPage-C1th2cZE.js +0 -2
  132. package/apps/web/dist/assets/EditorPage-56sIqEfF.js +0 -3
  133. package/apps/web/dist/assets/LangSwitch-CJ00IgaO.js +0 -1
  134. package/apps/web/dist/assets/Marketplace-D7-ot9Dz.js +0 -2
  135. package/apps/web/dist/assets/NewWizardPage-CytheHxX.js +0 -7
  136. package/apps/web/dist/assets/OnboardingPage-_91Pa8Ad.js +0 -1
  137. package/apps/web/dist/assets/PreviewPane-BDsYm-_K.js +0 -7
  138. package/apps/web/dist/assets/ProtocolSection-D_zaxHEL.js +0 -1
  139. package/apps/web/dist/assets/PublicRunner-CEgXSk3r.js +0 -1
  140. package/apps/web/dist/assets/SettingsPage-Dr8SDk-L.js +0 -2
  141. package/apps/web/dist/assets/SetupPage-B68n0l4I.js +0 -1
  142. package/apps/web/dist/assets/SharePage-DfznN7ar.js +0 -1
  143. package/apps/web/dist/assets/SkillEditor-BIcIczRc.js +0 -1
  144. package/apps/web/dist/assets/SpacePage-DiVTwhnJ.js +0 -2
  145. package/apps/web/dist/assets/changelog-a_CuplMX.js +0 -1
  146. package/apps/web/dist/assets/i18n-BaPKbQ1s.js +0 -55
  147. package/apps/web/dist/assets/index-CCUG6Vnh.css +0 -1
  148. package/apps/web/dist/assets/index-De0Wb42y.js +0 -10
  149. package/apps/web/dist/assets/session-BMiUrqHg.js +0 -2
@@ -2,7 +2,8 @@
2
2
  * The broker's first part (docs/plans/broker.md, "First: RWX"): the words of a space's rules.
3
3
  * A rule says who (a subject) may read, write or execute what (a resource); each flag is allow,
4
4
  * deny or unset. Unset means deny, and a deny wins over every allow from any other rule. The
5
- * runtime decides in apps/runtime/src/broker/rwx.ts; the studio will draw the rows as sentences.
5
+ * runtime decides in apps/runtime/src/broker/rwx.ts; the studio draws the rows as sentences in
6
+ * Fähigkeiten › Rechte (apps/web/src/studio/capabilities/rights-words.ts).
6
7
  */
7
8
  /**
8
9
  * Who a rule is about. A role's id is `member`, `admin` or `owner`; a guest has none. `agent`: an
@@ -54,3 +55,70 @@ export const RWX_LIMITS = {
54
55
  /** Characters of a subject's or resource's id. */
55
56
  id: 200,
56
57
  };
58
+ const EVERY_READER = ["guest", "person", "role", "goose", "wizard", "plugin", "agent"];
59
+ /** Every reader but a plugin, which reads pages and documents only (`spaceData`). */
60
+ const NO_PLUGIN = ["guest", "person", "role", "goose", "wizard", "agent"];
61
+ /** Goose for a person: its own rows, the person's and their role's. */
62
+ const THROUGH_GOOSE = ["person", "role", "goose"];
63
+ /** A person, or an AI working for one: a Work chat, a client's chat, an outside client. */
64
+ const A_PERSON = ["person", "role", "agent"];
65
+ /**
66
+ * What the runtime asks today, and so all a rule can say: per kind of resource and permission, the
67
+ * kinds of subject a reader asks it for. A rule outside this table would be stored and never
68
+ * asked, so the runtime refuses it (apps/runtime/src/broker/rwx.ts `refusalOf`), and the studio
69
+ * offers nothing else. A reader that starts asking adds its line here.
70
+ *
71
+ * - `document`, `page`, `table` · `r`: every reader of Knowledge (the studio's routes, a run's
72
+ * step, a Work chat, Goose, search, a share link, the client portal); a plugin reads pages and
73
+ * documents. A folder's rule is a rule on its page.
74
+ * - `page` · `w`: Goose writing a page of Knowledge for its person (`write_knowledge_page`). Not
75
+ * for the role `client`, and neither is the setup: a client reaches no studio (`rwxAsked`).
76
+ * - `wizard` · `r`, `x`: `wizard_list` and `wizard_run` for a person in a Work chat or through an
77
+ * outside client, and the client portal's list and start. A guest reaches a wizard by its link,
78
+ * and a person starting one in Work or the studio is not asked.
79
+ * - `skill` · `r`: `skill_list`, `skill_load`, `skill_read` in a step, a Work chat, for Goose and
80
+ * outside clients. `x`: its scripts placed in a sandbox, which Goose has none of.
81
+ * - `setup` · `w`: Goose's writes to the space's setup.
82
+ * - `mount` · `r`: `readableMounts`; `w`: a draft and „Veröffentlichen“ (mounts/drafts.ts), which a
83
+ * wizard is refused before any rule is asked. Its rules are written by its form in Dateien alone.
84
+ * - `connection`, `mail`, `host`, `sandbox`: nothing. A connection has its own audience and rules
85
+ * (broker/call.ts), which decide mail too; a run's grant decides hosts; the sandbox is a step's.
86
+ */
87
+ export const RWX_ASKED = {
88
+ document: { r: EVERY_READER },
89
+ table: { r: NO_PLUGIN },
90
+ page: { r: EVERY_READER, w: THROUGH_GOOSE },
91
+ wizard: { r: A_PERSON, x: A_PERSON },
92
+ skill: { r: NO_PLUGIN, x: ["guest", "person", "role", "wizard", "agent"] },
93
+ setup: { w: THROUGH_GOOSE },
94
+ mount: { r: NO_PLUGIN, w: A_PERSON },
95
+ connection: {},
96
+ mail: {},
97
+ host: {},
98
+ sandbox: {},
99
+ };
100
+ /**
101
+ * What only Goose asks. Goose works for the people in the studio, and a client of the
102
+ * organization reaches no studio: for the role `client` this is asked by nobody.
103
+ */
104
+ const GOOSE_ALONE = {
105
+ page: ["w"],
106
+ setup: ["w"],
107
+ };
108
+ /**
109
+ * Whether a reader asks `perm` on a resource of `kind` for a subject of `subject`; `subjectId`
110
+ * tells the roles apart, where it is known.
111
+ */
112
+ export const rwxAsked = (subject, kind, perm, subjectId) => (RWX_ASKED[kind][perm]?.includes(subject) ?? false) &&
113
+ !(subject === "role" && subjectId === "client" && GOOSE_ALONE[kind]?.includes(perm));
114
+ /**
115
+ * Where a rule is set, and so where it is changed: the start set every space has (a role's or the
116
+ * guests' rule on every resource of a kind), „Wer sieht diesen Ordner“ on a page of Wissen, a
117
+ * mount's form in Dateien, „Für Kund:innen sichtbar“, or Fähigkeiten › Rechte. It is read off the
118
+ * rule: a place that shows a rule also replaces it, whoever wrote the row.
119
+ */
120
+ export const RWX_ORIGINS = ["start", "folder", "mount", "clients", "rights"];
121
+ /** Whom „Was darf …?“ asks about for content. */
122
+ export const RWX_ASK_WHO = ["guest", "person", "goose", "agent", "wizard", "plugin"];
123
+ /** What „Was darf …?“ asks about for content: the kinds decided by one rule lookup. */
124
+ export const RWX_ASK_KINDS = ["document", "page", "table", "wizard", "skill", "setup"];
@@ -8,8 +8,11 @@
8
8
  /** When a skill counts: in every AI step, when a step reads it, or not at all. */
9
9
  export declare const SKILL_MODES: readonly ["always", "demand", "off"];
10
10
  export type SkillMode = (typeof SKILL_MODES)[number];
11
- /** Where it came from: written in the studio, uploaded, or added from skills.sh. */
12
- export declare const SKILL_SOURCES: readonly ["own", "upload", "skills.sh"];
11
+ /**
12
+ * Where it came from: written in the studio, uploaded, added from skills.sh, or brought by a
13
+ * plugin together with a connector (`bundles.ts`).
14
+ */
15
+ export declare const SKILL_SOURCES: readonly ["own", "upload", "skills.sh", "plugin"];
13
16
  export type SkillSource = (typeof SKILL_SOURCES)[number];
14
17
  export declare const SKILL_LIMITS: {
15
18
  /** A name, as the Agent Skills format allows it. */
@@ -59,6 +62,15 @@ export interface SkillBlobFile {
59
62
  hash: string;
60
63
  bytes: number;
61
64
  }
65
+ /** What a skill came with: the record of a plugin taken into the space, and its connectors. */
66
+ export interface SkillBundle {
67
+ id: string;
68
+ name: string;
69
+ connectors: {
70
+ id: string;
71
+ name: string;
72
+ }[];
73
+ }
62
74
  /** A skill as the list shows it. */
63
75
  export interface SkillSummary {
64
76
  id: string;
@@ -66,9 +78,14 @@ export interface SkillSummary {
66
78
  description: string;
67
79
  mode: SkillMode;
68
80
  source: SkillSource;
69
- /** skills.sh: `owner/repo/skill`. */
81
+ /** skills.sh: `owner/repo/skill`. A plugin's: its folder in the plugin. */
70
82
  origin: string | null;
71
83
  official: boolean;
84
+ /**
85
+ * A plugin's: what it came with, by the plugin's name, and the connectors that came with it.
86
+ * Such a skill is read only; a copy of it is the space's own.
87
+ */
88
+ bundle: SkillBundle | null;
72
89
  /** Its scripts run in the sandbox of a step that has one. Off until someone switches it on. */
73
90
  runScripts: boolean;
74
91
  /** Its files beside the `SKILL.md`, the ones for scripts too. */
@@ -7,8 +7,11 @@
7
7
  */
8
8
  /** When a skill counts: in every AI step, when a step reads it, or not at all. */
9
9
  export const SKILL_MODES = ["always", "demand", "off"];
10
- /** Where it came from: written in the studio, uploaded, or added from skills.sh. */
11
- export const SKILL_SOURCES = ["own", "upload", "skills.sh"];
10
+ /**
11
+ * Where it came from: written in the studio, uploaded, added from skills.sh, or brought by a
12
+ * plugin together with a connector (`bundles.ts`).
13
+ */
14
+ export const SKILL_SOURCES = ["own", "upload", "skills.sh", "plugin"];
12
15
  export const SKILL_LIMITS = {
13
16
  /** A name, as the Agent Skills format allows it. */
14
17
  name: 64,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engenty/wizards-runtime",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "description": "Make a wish. Get your wizard. It guides you step by step. Let AI do the work. Runs on your machine, on the AI subscription you already have. The runtime, which `npx wizards` installs.",
5
5
  "license": "FSL-1.1-MIT AND CC-BY-4.0",
6
6
  "homepage": "https://engenty.ai",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wizards",
3
3
  "displayName": "engenty wizards",
4
- "version": "0.17.0",
4
+ "version": "0.17.2",
5
5
  "description": "Build page-by-page AI wizards that people open on a shared link — designed, tested and published from Claude Code — run your published ones in the chat, and keep them in a pane beside it.",
6
6
  "author": {
7
7
  "name": "engenty"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "engenty-wizards",
4
- "version": "0.17.0",
4
+ "version": "0.17.2",
5
5
  "description": "Build page-by-page AI wizards that people open on a shared link, test and publish them from the chat, and run your published ones here.",
6
6
  "author": {
7
7
  "name": "engenty",
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SkillEditor-BIcIczRc.js","assets/rolldown-runtime-hePW80VL.js","assets/jsx-runtime-BNakU3Ej.js","assets/ui-DAk_vjrL.js","assets/preload-helper-DpV6A1kQ.js","assets/marked.esm-DQ7XA7AC.js","assets/i18n-BaPKbQ1s.js","assets/useMutation-isHfB33W.js","assets/Skills-CN4QE7Kx.js","assets/circle-check-DDLzlcXP.js","assets/upload-CAlHC232.js","assets/code-xml-S4IFi5Jc.js","assets/scroll-text-BEnPzQEi.js","assets/eye-TJSuiHHO.js","assets/code-editor-DkPo1C-L.js","assets/dist-CQpLJoQZ.js","assets/w3c-keyname-BOAvb0qz.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Cn as i,Q as a,S as o,Tn as s,Vr as c,X as l,Yn as u,Zn as d,cr as f,en as p,g as m,gr as h,hn as g,hr as _,lr as v,mr as y,nn as b,or as x,pn as S,pr as C,rn as w,tn as T,un as E}from"./ui-DAk_vjrL.js";import{t as D}from"./useMutation-isHfB33W.js";import{t as O}from"./preload-helper-DpV6A1kQ.js";import{d as k,i as A,u as j}from"./marked.esm-DQ7XA7AC.js";import{In as M,a as N,fn as P,l as F,m as ee,p as I,pn as te,t as ne,vn as re}from"./host-D6H6Z9Jp.js";import{a as ie,f as ae,o as oe,r as se,s as L}from"./Skills-CN4QE7Kx.js";import{n as R}from"./volume-2-BqlBtCIJ.js";import{a as ce,c as z,i as le,n as ue,o as de,r as fe,s as pe}from"./ProtocolSection-D_zaxHEL.js";import{t as B}from"./scroll-text-BEnPzQEi.js";import{b as me,d as V,u as H}from"./session-BMiUrqHg.js";import{n as he,s as U}from"./i18n-BaPKbQ1s.js";import{a as ge,c as _e,d as ve,f as ye,i as be,m as W,p as xe,r as Se,u as G}from"./UpdateCheck-QhBI3rlQ.js";var K={name:`compass`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]};K.node;var Ce=k(K),q=e(t(),1),J=e(n(),1),we=[`discover.example1`,`discover.example2`,`discover.example3`],Y=(e,t)=>t===void 0?[`discover`,e]:[`discover`,e,t];function Te(){let[e,t]=f(),n=e.get(`q`)??``,[r,i]=(0,q.useState)(n);return(0,q.useEffect)(()=>i(e=>e.trim()===n.trim()?e:n),[n]),(0,q.useEffect)(()=>{let e=r.trim();if(e===n.trim())return;let i=setTimeout(()=>t(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n},{replace:!0}),350);return()=>clearTimeout(i)},[r,n,t]),[r,i,n.trim()]}function Ee({asked:e,onExample:t}){let{space:n}=H(),i=V(),o=P(`skills`),u=c(),[d,f]=(0,q.useState)(null),p=n?.id??``,m=h({queryKey:Y(p,e),queryFn:()=>a.get(`/api/studio/spaces/${p}/discover?q=${encodeURIComponent(e)}`),enabled:!!p&&e.length>=2,staleTime:6e4}),g=e=>{u.setQueriesData({queryKey:Y(p)},t=>t&&{...t,skills:t.skills.map(t=>t.ref===e?{...t,added:!0}:t)}),u.invalidateQueries({queryKey:l.skills(p)})},_=D({mutationFn:e=>a.post(`/api/studio/spaces/${p}/skills/registry`,{ref:e,mode:`demand`}),onSuccess:(e,t)=>g(t)}),v=m.data,y=v&&!v.skills.length&&!v.connectors.length&&!v.errors.skills&&!v.errors.connectors;return n?(0,J.jsxs)(J.Fragment,{children:[e.length<2?(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 px-1 text-[0.875rem] text-ink-3`,children:[(0,J.jsx)(`p`,{children:U(`discover.start`)}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:we.map(e=>(0,J.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>t(U(e)),children:[(0,J.jsx)(s,{className:`size-3.5`}),` `,U(e)]},e))})]}):m.error?(0,J.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:m.error.message}):v?y?(0,J.jsx)(`p`,{className:`px-1 text-[0.875rem] text-ink-3`,children:U(`discover.none`,{q:e})}):(0,J.jsxs)(J.Fragment,{children:[o?(0,J.jsx)(X,{title:U(`space.skills`),count:v.skills.length,error:v.errors.skills,empty:U(`discover.groupNone`,{directory:`skills.sh`}),children:v.skills.map(e=>(0,J.jsx)(De,{hit:e,adding:_.isPending&&_.variables===e.ref,failed:_.isError&&_.variables===e.ref?_.error:null,onLook:()=>f(e.ref),onAdd:()=>_.mutate(e.ref)},e.ref))}):null,(0,J.jsx)(X,{title:U(`capabilities.connectors`),count:v.connectors.length,error:v.errors.connectors,empty:U(`discover.groupNone`,{directory:`integrations.sh`}),children:v.connectors.map(e=>(0,J.jsx)(Oe,{hit:e,admin:i},e.domain))})]}):(0,J.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,J.jsx)(E,{className:`size-5`})}),(0,J.jsx)(b,{open:d!==null,onClose:()=>f(null),wide:!0,height:`tall`,title:U(`skills.registryTitle`),children:d?(0,J.jsx)(se,{spaceId:p,skillRef:d,onAdded:()=>{g(d),f(null)}},d):null})]}):null}function X({title:e,count:t,error:n,empty:r,children:i}){return(0,J.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-baseline gap-2 px-1`,children:[(0,J.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:e}),t?(0,J.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3`,children:t}):null]}),n?(0,J.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:n}):t?(0,J.jsx)(p,{className:`divide-y divide-border-soft`,children:i}):(0,J.jsx)(`p`,{className:`px-1 text-[0.875rem] text-ink-3`,children:r})]})}function Z({icon:e,name:t,mono:n,chip:r,line:i,source:a,error:o,children:s}){return(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-3 sm:flex-nowrap`,children:[(0,J.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-paper-2 text-ink-3`,children:(0,J.jsx)(e,{className:`size-4`})}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 max-sm:basis-[calc(100%-3.25rem)]`,children:[(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`span`,{className:n?`font-medium font-mono text-[0.8125rem]`:`font-medium`,children:t}),r]}),i?(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-[0.8125rem] text-ink-2`,children:i}):null,(0,J.jsx)(`span`,{className:`mt-0.5 block truncate text-[0.75rem] text-ink-3`,children:a}),o?(0,J.jsx)(`span`,{className:`mt-1 block text-[0.8125rem] text-rose`,children:o}):null]}),(0,J.jsx)(`span`,{className:`flex shrink-0 items-center gap-2 max-sm:ml-[3.25rem]`,children:s})]})}function Q(){return(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[0.8125rem] text-moss`,children:[(0,J.jsx)(j,{className:`size-4`}),` `,U(`capabilities.inSpace`)]})}function De({hit:e,adding:t,failed:n,onLook:i,onAdd:a}){return(0,J.jsxs)(Z,{icon:B,name:e.name,mono:!0,chip:e.official?(0,J.jsx)(T,{tone:`live`,icon:(0,J.jsx)(ae,{className:`size-3`}),children:U(`skills.official`)}):(0,J.jsx)(T,{tone:`warn`,children:U(`skills.unchecked`)}),error:n?.message,source:[`skills.sh`,e.source,U(`skills.installs`,{n:e.installs.toLocaleString(he)})].join(` · `),children:[(0,J.jsx)(r,{variant:`ghost`,size:`sm`,onClick:i,children:U(`skills.open`)}),e.added?(0,J.jsx)(Q,{}):(0,J.jsx)(r,{variant:`secondary`,size:`sm`,busy:t,onClick:a,children:U(`skills.add`)})]})}function Oe({hit:e,admin:t}){let n=y(),i=e.kinds.map(e=>e===`mcp`?`MCP`:`OpenAPI`);return(0,J.jsx)(Z,{icon:R,name:e.name,line:e.description||void 0,source:[`integrations.sh`,e.domain,...i].join(` · `),children:e.setUp?(0,J.jsx)(Q,{}):t?(0,J.jsx)(r,{variant:`secondary`,size:`sm`,onClick:()=>n(`/capabilities/connectors?setup=${encodeURIComponent(e.domain)}`),children:U(`discover.setUp`)}):null})}var $={skills:4,connections:5};function ke(){let{space:e}=H(),t=V(),n=y(),r=P(`skills`),i=P(`unsetConnectors`),[a,c]=f(),l=a.get(`tab`)===`discover`?`discover`:`space`,[u,d,m]=Te(),h=e?.id??``,g=L(r?e?.id:void 0),_=z(h),v=pe(h);if(!e)return null;let b=t&&!e.readOnly,C=u.trim().toLowerCase(),T=g.data?.skills??[],E=_.data?.connections??[],D=T.filter(e=>e.mode!==`off`).sort((e,t)=>e.mode===t.mode?0:e.mode===`always`?-1:1),O=C?T.filter(e=>e.name.includes(C)||e.description.toLowerCase().includes(C)):D,k=C?E.filter(e=>`${e.name} ${e.connector?.name??e.connectorId}`.toLowerCase().includes(C)):E,A=de(v.data??[],E,i),j=e=>c(t=>{let n=new URLSearchParams(t);return e===`discover`?n.set(`tab`,`discover`):n.delete(`tab`),n},{replace:!0});return(0,J.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[(0,J.jsx)(o,{title:U(`nav.capabilities`),hint:U(`capabilities.overview.hint`),plain:!0,action:(0,J.jsx)(Me,{entries:[...r&&!g.data?.readOnly?[{icon:B,label:U(`capabilities.overview.addSkill`),hint:U(`capabilities.overview.addSkillHint`),to:`/capabilities/skills`}]:[],...b?[{icon:R,label:U(`capabilities.overview.addConnection`),hint:U(`capabilities.overview.addConnectionHint`),to:`/capabilities/connectors?setup=`}]:[],{icon:Ce,label:U(`capabilities.discover`),hint:U(`capabilities.overview.discoverHint`),to:`/capabilities/overview?tab=discover`}]}),children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(S,{value:l,onChange:j,options:[{id:`space`,label:U(`capabilities.inSpace`)},{id:`discover`,label:U(`capabilities.discover`)}],label:U(`nav.capabilities`)}),(0,J.jsxs)(`form`,{className:`flex h-10 min-w-0 flex-1 basis-60 items-center gap-2 rounded-full border border-input bg-card px-4 focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow`,onSubmit:e=>{e.preventDefault(),l===`space`&&C&&!O.length&&!k.length&&j(`discover`)},children:[(0,J.jsx)(s,{className:`size-4 shrink-0 text-ink-3`}),(0,J.jsx)(`input`,{type:`search`,value:u,"aria-label":U(l===`discover`?`discover.searchLabel`:`capabilities.overview.search`),placeholder:U(l===`discover`?`discover.search`:`capabilities.overview.search`),onChange:e=>d(e.target.value),className:`min-w-0 flex-1 bg-transparent text-[0.875rem] text-ink outline-none placeholder:text-ink-4`})]})]})}),(0,J.jsx)(`div`,{className:`flex animate-rise flex-col gap-9`,children:l===`discover`?(0,J.jsx)(Ee,{asked:m,onExample:d}):(0,J.jsxs)(J.Fragment,{children:[r?(0,J.jsx)(Ae,{icon:B,title:U(`space.skills`),all:T.length,to:`/capabilities/skills`,children:g.error?(0,J.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:g.error.message}):O.length?(0,J.jsx)(`div`,{className:`grid gap-2.5 sm:grid-cols-2`,children:O.slice(0,$.skills).map(e=>(0,J.jsx)(je,{skill:e,onOpen:()=>n(`/capabilities/skills?show=k:${e.id}`)},e.id))}):g.isPending?null:(0,J.jsx)(p,{children:(0,J.jsx)(w,{children:C?U(`capabilities.overview.nothing`,{q:u.trim()}):U(`capabilities.overview.noSkills`)})})}):null,(0,J.jsxs)(Ae,{icon:R,title:U(`capabilities.connectors`),all:E.length,to:`/capabilities/connectors`,children:[b&&!C?(0,J.jsx)(ce,{connections:E,onOpen:e=>n(`/capabilities/connectors?show=${encodeURIComponent(e)}`)}):null,_.error?(0,J.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:_.error.message}):k.length?(0,J.jsx)(p,{className:`flex flex-col divide-y divide-border-soft p-0`,children:k.slice(0,$.connections).map(e=>(0,J.jsx)(fe,{connection:e,onOpen:()=>n(`/capabilities/connectors?show=${encodeURIComponent(e.id)}`)},e.id))}):_.isPending?null:(0,J.jsx)(p,{children:(0,J.jsx)(w,{children:C?U(`capabilities.overview.nothing`,{q:u.trim()}):U(`capabilities.overview.noConnections`)})}),A.length&&!C?(0,J.jsxs)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:[U(`capabilities.connectors.builtin`),`:`,` `,A.map((e,t)=>(0,J.jsxs)(`span`,{children:[t?` · `:null,b&&e.usable?(0,J.jsx)(x,{to:`/capabilities/connectors?setup=${encodeURIComponent(e.id)}`,className:`text-ink-2 hover:text-ink hover:underline`,children:e.name}):(0,J.jsx)(`span`,{className:`text-ink-2`,children:e.name})]},e.id))]}):null]})]})},l)]})}function Ae({icon:e,title:t,all:n,to:r,children:i}){return(0,J.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1`,children:[(0,J.jsxs)(`h3`,{className:`flex items-center gap-2 font-semibold text-[0.9375rem]`,children:[(0,J.jsx)(e,{className:`size-4 text-ember-strong`,"aria-hidden":`true`}),t]}),(0,J.jsxs)(x,{to:r,className:`inline-flex items-center gap-0.5 text-[0.8125rem] text-ink-3 transition hover:text-ink`,children:[U(`capabilities.overview.all`,{n}),(0,J.jsx)(u,{className:`size-3.5`,"aria-hidden":`true`})]})]}),i]})}function je({skill:e,onOpen:t}){return(0,J.jsxs)(`button`,{type:`button`,onClick:t,className:`flex min-w-0 flex-col gap-1.5 rounded-xl bg-card px-4 py-3 text-left shadow-soft ring-1 ring-border-soft transition hover:ring-border`,children:[(0,J.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:g(`truncate font-medium font-mono text-[0.8125rem]`,e.mode===`off`&&`text-ink-3`),children:e.name}),(0,J.jsx)(T,{tone:e.mode===`always`?`live`:`neutral`,children:U(`skills.mode.${e.mode}`)})]}),(0,J.jsx)(`span`,{className:`line-clamp-2 text-[0.8125rem] text-ink-2`,children:e.description}),(0,J.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-[0.75rem] text-ink-3`,children:[(0,J.jsx)(oe,{skill:e}),e.runScripts?U(`capabilities.overview.scripts`):null]})]})}function Me({entries:e}){let[t,n]=(0,q.useState)(!1),i=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(!t)return;let e=e=>{i.current?.contains(e.target)||n(!1)},r=e=>e.key===`Escape`&&n(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,r),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,r)}},[t]),(0,J.jsxs)(`div`,{className:`relative`,ref:i,children:[(0,J.jsxs)(r,{size:`sm`,"aria-haspopup":`menu`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,J.jsx)(A,{className:`size-4`}),` `,U(`skills.add`),(0,J.jsx)(d,{className:`-mr-1 size-4`})]}),t?(0,J.jsx)(`div`,{role:`menu`,className:`absolute top-10 right-0 z-50 w-72 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:e.map(e=>(0,J.jsxs)(x,{to:e.to,role:`menuitem`,onClick:()=>n(!1),className:`flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left transition hover:bg-accent`,children:[(0,J.jsx)(e.icon,{className:`mt-0.5 size-4 shrink-0 text-ink-3`}),(0,J.jsxs)(`span`,{className:`min-w-0`,children:[(0,J.jsx)(`span`,{className:`block font-medium text-[0.875rem]`,children:e.label}),(0,J.jsx)(`span`,{className:`block text-[0.8125rem] text-ink-3`,children:e.hint})]})]},e.to))}):null]})}var Ne=(0,q.lazy)(()=>O(()=>import(`./SkillEditor-BIcIczRc.js`).then(e=>({default:e.SkillEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])));function Pe(){let[e,t]=f(),{space:n}=H(),r=N(),{narrow:i}=xe(),a=e.get(`show`),s=a?.startsWith(`k:`)?a:null,c=L(n?.id),l=F(`skills`,r).filter(e=>e.plugin);ve(c.data?.skills.find(e=>`k:${e.id}`===s)?.name??null),(0,q.useEffect)(()=>{i||I().scrollTo({top:0})},[i,s]);let u=e=>i?t({show:e}):t(e===`all`?{}:{show:e},{replace:!0});return(0,J.jsx)(J.Fragment,{children:n?(0,J.jsx)(`div`,{className:`flex flex-col gap-9 pb-20`,children:s?(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(Ne,{skillId:s.slice(2),onGone:()=>u(`all`),onOpen:u,filesFirst:!0},s)}):c.data?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ie,{spaceId:n.id,data:c.data,onOpen:u,heading:U(`capabilities.inSpace`)}),l.flatMap(e=>e.sections).map(e=>r.spaceSections.find(t=>t.id===e.id)).filter(e=>e!==void 0).map(e=>(0,J.jsx)(m,{id:e.id,children:(0,J.jsx)(o,{title:e.label(),hint:e.hint?.(),plain:!0,children:(0,J.jsx)(ne,{of:e,children:(0,J.jsx)(e.component,{})})})},e.serial))]}):c.error?(0,J.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:c.error.message}):null}):null})}var Fe=[{id:`overview`,label:`capabilities.overview`,icon:M,element:ke,menu:!1},{id:`skills`,label:`space.skills`,icon:B,element:Pe,feature:`skills`,menu:!1},{id:`connectors`,label:`capabilities.connectors`,icon:R,element:le,menu:!1},{id:`protocol`,label:`capabilities.protocol`,icon:i,element:ue,menu:!1}];function Ie(e){return Fe.filter(t=>t.element&&(!t.feature||e(t.feature)))}function Le(){let[e,t]=(0,q.useState)(null);return(0,q.useEffect)(()=>{let e=I(),n=()=>t(e.clientHeight);n();let r=new ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),e}function Re(){let e=P(`capabilities`),t=te(),{section:n}=_(),[r]=f(),i=y(),a=C(),{space:o,loading:s}=H(),c=ye(),[l,u]=(0,q.useState)(null),[d,p]=(0,q.useState)(null),[m,h]=(0,q.useState)(null),b=Ie(e=>me(t,e)),x=b.find(e=>e.id===n),S=L(b.some(e=>e.id===`skills`)?o?.id:void 0),T=z(o?.id??``),E={skills:S.data?.skills.length,connectors:T.data?.connections.length},D=b.map(e=>({id:e.id,label:U(e.label),icon:e.icon,to:e.menu===!1&&c?`/capabilities/${e.id}?show=page`:`/capabilities/${e.id}`,count:E[e.id]})),O=D.find(e=>e.id===x?.id),k=r.get(`show`)||r.has(`setup`)?2:1,A=x&&x.menu!==!1&&m!==x.id?1:0,j=W(A),M=W(k),N=(0,q.useMemo)(()=>({slot:l,narrow:c,setDetail:p}),[l,c]),F=Le();if(ee([{label:U(`nav.capabilities`),to:`/capabilities`},...O?[{label:O.label,to:O.to}]:[],...O&&d?[{label:d}]:[]]),!e)return(0,J.jsx)(v,{to:`/`,replace:!0});if(n===`discover`){let e=new URLSearchParams(a.search);return e.set(`tab`,`discover`),(0,J.jsx)(v,{to:{pathname:`/capabilities/overview`,search:`?${e}`},replace:!0})}if(!x&&b[0])return(0,J.jsx)(v,{to:{pathname:`/capabilities/${b[0].id}`,search:a.search},replace:!0});let I=x?.element;return(0,J.jsx)(_e.Provider,{value:N,children:(0,J.jsx)(`div`,{className:`animate-rise`,children:(0,J.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-[10.5rem_minmax(0,1fr)] md:gap-5 lg:grid-cols-[15rem_minmax(0,1fr)] lg:gap-10`,children:[(0,J.jsxs)(`aside`,{className:g(`menu-scroll min-w-0 md:sticky md:top-6 md:self-start md:overflow-y-auto md:overscroll-contain`,c&&k===2&&`hidden`,c&&M===`back`&&G(`back`)),style:!c&&F?{maxHeight:F-48,paddingBottom:`var(--assistant-dock, 0px)`}:void 0,children:[(0,J.jsx)(be,{title:U(`nav.capabilities`),open:A===1?O??null:null,onBack:b.length>1?()=>h(x?.id??null):void 0,root:{icon:re,label:U(`nav.capabilities`),onOpen:()=>i(c?`/capabilities/overview?show=page`:`/capabilities/overview`),current:x?.id===`overview`}}),(0,J.jsx)(`div`,{className:g(G(j)),children:A===0?(0,J.jsx)(ge,{entries:D.filter(e=>e.id!==`overview`),current:O,onPick:e=>{h(null),x?.menu===!1&&i(e.to)}}):(0,J.jsx)(`div`,{ref:u})},A)]}),(0,J.jsxs)(`div`,{className:g(`min-w-0`,c&&k<2&&`hidden`,c&&M===`deeper`&&G(`deeper`)),children:[c&&O?(0,J.jsx)(`div`,{className:`mb-3`,children:(0,J.jsx)(Se,{label:O.label,onBack:()=>i(O.to)})}):null,I?(0,J.jsx)(I,{}):null,o||s?null:(0,J.jsx)(w,{children:U(`settings.noSpace`)})]})]})})})}export{Re as CapabilitiesPage};