@rise-x/apps-sdk 0.6.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/LICENSE +1 -0
- package/README.md +553 -0
- package/build/_internal.d.ts +2 -0
- package/build/_internal.js +23 -0
- package/build/accessors.d.ts +8 -0
- package/build/accessors.js +40 -0
- package/build/cli/index.d.ts +13 -0
- package/build/cli/index.js +54 -0
- package/build/cli/init.d.ts +6 -0
- package/build/cli/init.js +179 -0
- package/build/cli/templating.d.ts +2 -0
- package/build/cli/templating.js +84 -0
- package/build/connectors/agents.d.ts +85 -0
- package/build/connectors/agents.js +404 -0
- package/build/connectors/assets.d.ts +76 -0
- package/build/connectors/assets.js +204 -0
- package/build/connectors/deps.d.ts +4 -0
- package/build/connectors/deps.js +2 -0
- package/build/connectors/errors.d.ts +11 -0
- package/build/connectors/errors.js +67 -0
- package/build/connectors/flows.d.ts +37 -0
- package/build/connectors/flows.js +191 -0
- package/build/connectors/index.d.ts +8 -0
- package/build/connectors/index.js +50 -0
- package/build/connectors/sse.d.ts +12 -0
- package/build/connectors/sse.js +157 -0
- package/build/connectors/types.d.ts +285 -0
- package/build/connectors/types.js +419 -0
- package/build/connectors/work.d.ts +84 -0
- package/build/connectors/work.js +224 -0
- package/build/hooks.d.ts +4 -0
- package/build/hooks.js +28 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +34 -0
- package/build/lifecycle.d.ts +23 -0
- package/build/lifecycle.js +6 -0
- package/build/mockShell.d.ts +10 -0
- package/build/mockShell.js +55 -0
- package/build/query/agents.d.ts +80 -0
- package/build/query/agents.js +143 -0
- package/build/query/assets.d.ts +73 -0
- package/build/query/assets.js +152 -0
- package/build/query/client.d.ts +5 -0
- package/build/query/client.js +68 -0
- package/build/query/context.d.ts +2 -0
- package/build/query/context.js +34 -0
- package/build/query/flows.d.ts +54 -0
- package/build/query/flows.js +81 -0
- package/build/query/index.d.ts +10 -0
- package/build/query/index.js +85 -0
- package/build/query/keys.d.ts +51 -0
- package/build/query/keys.js +79 -0
- package/build/query/layer.d.ts +175 -0
- package/build/query/layer.js +35 -0
- package/build/query/shared.d.ts +43 -0
- package/build/query/shared.js +116 -0
- package/build/query/work.d.ts +75 -0
- package/build/query/work.js +172 -0
- package/build/shell/index.d.ts +1 -0
- package/build/shell/index.js +6 -0
- package/build/shell/installShellBridge.d.ts +11 -0
- package/build/shell/installShellBridge.js +104 -0
- package/build/shellBridge.d.ts +36 -0
- package/build/shellBridge.js +10 -0
- package/build/topBar.d.ts +25 -0
- package/build/topBar.js +17 -0
- package/build/ui/components/ai.d.ts +49 -0
- package/build/ui/components/alert-dialog.d.ts +27 -0
- package/build/ui/components/alert.d.ts +14 -0
- package/build/ui/components/avatar.d.ts +17 -0
- package/build/ui/components/badge.d.ts +19 -0
- package/build/ui/components/button.d.ts +13 -0
- package/build/ui/components/calendar.d.ts +21 -0
- package/build/ui/components/card.d.ts +16 -0
- package/build/ui/components/chart.d.ts +124 -0
- package/build/ui/components/checkbox.d.ts +4 -0
- package/build/ui/components/data-table.d.ts +70 -0
- package/build/ui/components/dialog.d.ts +17 -0
- package/build/ui/components/dropdown-menu.d.ts +29 -0
- package/build/ui/components/empty-state.d.ts +7 -0
- package/build/ui/components/file-upload.d.ts +17 -0
- package/build/ui/components/input.d.ts +8 -0
- package/build/ui/components/label.d.ts +4 -0
- package/build/ui/components/list.d.ts +24 -0
- package/build/ui/components/map.d.ts +26 -0
- package/build/ui/components/message.d.ts +24 -0
- package/build/ui/components/nav.d.ts +12 -0
- package/build/ui/components/page-header.d.ts +27 -0
- package/build/ui/components/popover.d.ts +10 -0
- package/build/ui/components/progress.d.ts +4 -0
- package/build/ui/components/radio.d.ts +6 -0
- package/build/ui/components/resizable.d.ts +7 -0
- package/build/ui/components/scroll-area.d.ts +5 -0
- package/build/ui/components/segmented.d.ts +6 -0
- package/build/ui/components/select.d.ts +15 -0
- package/build/ui/components/separator.d.ts +4 -0
- package/build/ui/components/sheet.d.ts +14 -0
- package/build/ui/components/skeleton.d.ts +3 -0
- package/build/ui/components/slider.d.ts +15 -0
- package/build/ui/components/snackbar.d.ts +3 -0
- package/build/ui/components/sonner.d.ts +4 -0
- package/build/ui/components/spinner.d.ts +5 -0
- package/build/ui/components/statistic.d.ts +19 -0
- package/build/ui/components/stepper.d.ts +12 -0
- package/build/ui/components/switch.d.ts +6 -0
- package/build/ui/components/table.d.ts +24 -0
- package/build/ui/components/textarea.d.ts +3 -0
- package/build/ui/components/timeline.d.ts +15 -0
- package/build/ui/components/toggle-group.d.ts +10 -0
- package/build/ui/components/toggle.d.ts +9 -0
- package/build/ui/components/tooltip.d.ts +7 -0
- package/build/ui/index.d.ts +46 -0
- package/build/ui/index.js +8 -0
- package/build/ui/lib/utils.d.ts +2 -0
- package/build/ui/reference/README.md +11 -0
- package/build/ui/reference/components/ai.tsx +291 -0
- package/build/ui/reference/components/alert-dialog.tsx +208 -0
- package/build/ui/reference/components/alert.tsx +112 -0
- package/build/ui/reference/components/avatar.tsx +158 -0
- package/build/ui/reference/components/badge.tsx +160 -0
- package/build/ui/reference/components/button.tsx +100 -0
- package/build/ui/reference/components/calendar.tsx +119 -0
- package/build/ui/reference/components/card.tsx +144 -0
- package/build/ui/reference/components/chart.tsx +1394 -0
- package/build/ui/reference/components/checkbox.tsx +44 -0
- package/build/ui/reference/components/data-table.tsx +480 -0
- package/build/ui/reference/components/dialog.tsx +172 -0
- package/build/ui/reference/components/dropdown-menu.tsx +245 -0
- package/build/ui/reference/components/empty-state.tsx +63 -0
- package/build/ui/reference/components/file-upload.tsx +116 -0
- package/build/ui/reference/components/input.tsx +114 -0
- package/build/ui/reference/components/label.tsx +19 -0
- package/build/ui/reference/components/list.tsx +191 -0
- package/build/ui/reference/components/map.css +251 -0
- package/build/ui/reference/components/map.tsx +294 -0
- package/build/ui/reference/components/message.tsx +171 -0
- package/build/ui/reference/components/nav.tsx +113 -0
- package/build/ui/reference/components/page-header.tsx +213 -0
- package/build/ui/reference/components/popover.tsx +76 -0
- package/build/ui/reference/components/progress.tsx +31 -0
- package/build/ui/reference/components/radio.tsx +65 -0
- package/build/ui/reference/components/resizable.tsx +40 -0
- package/build/ui/reference/components/scroll-area.tsx +55 -0
- package/build/ui/reference/components/segmented.tsx +45 -0
- package/build/ui/reference/components/select.tsx +185 -0
- package/build/ui/reference/components/separator.tsx +26 -0
- package/build/ui/reference/components/sheet.tsx +173 -0
- package/build/ui/reference/components/skeleton.tsx +15 -0
- package/build/ui/reference/components/slider.tsx +161 -0
- package/build/ui/reference/components/snackbar.tsx +27 -0
- package/build/ui/reference/components/sonner.tsx +43 -0
- package/build/ui/reference/components/spinner.tsx +27 -0
- package/build/ui/reference/components/statistic.tsx +122 -0
- package/build/ui/reference/components/stepper.tsx +138 -0
- package/build/ui/reference/components/switch.tsx +47 -0
- package/build/ui/reference/components/table.tsx +233 -0
- package/build/ui/reference/components/textarea.tsx +28 -0
- package/build/ui/reference/components/timeline.tsx +94 -0
- package/build/ui/reference/components/toggle-group.tsx +86 -0
- package/build/ui/reference/components/toggle.tsx +46 -0
- package/build/ui/reference/components/tooltip.tsx +53 -0
- package/build/ui/reference/index.ts +49 -0
- package/build/ui/reference/lib/utils.ts +34 -0
- package/build/ui/standalone-stub.js +5 -0
- package/build/ui/standalone.js +135 -0
- package/build/ui/styles.css +3 -0
- package/connectors/package.json +8 -0
- package/package.json +114 -0
- package/query/package.json +8 -0
- package/shell/package.json +8 -0
- package/template/AGENTS.md +70 -0
- package/template/CLAUDE.md +4 -0
- package/template/README.md +102 -0
- package/template/_gitignore +6 -0
- package/template/commitlint.config.js +12 -0
- package/template/package.json +31 -0
- package/template/public/index.html +13 -0
- package/template/src/App.tsx +171 -0
- package/template/src/bootstrap.tsx +13 -0
- package/template/src/index.tsx +1 -0
- package/template/src/lifecycle.ts +20 -0
- package/template/tsconfig.json +31 -0
- package/template/webpack.config.js +112 -0
- package/template/webpack.local.config.js +68 -0
- package/ui/package.json +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright (c) 2026 Rise-X Digital Services Pty Ltd. All rights reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
# @rise-x/apps-sdk
|
|
2
|
+
|
|
3
|
+
SDK for building federated apps on top of the Rise-X Diana shell.
|
|
4
|
+
|
|
5
|
+
- **Runtime hooks/accessors** — `useShellUser`, `useShellEnvironment`, `useShellNavigate`, `getShellApi`, `getShellApiV4`, `getShellAi`.
|
|
6
|
+
- **Connectors** — `@rise-x/apps-sdk/connectors` exposes typed, higher-level API wrappers (`flows`, `work`, `assets`, `agents`) so apps don't hand-roll multi-step API calls.
|
|
7
|
+
- **Lifecycle hooks** — `onInstall`, `onUpdate`, `onUninstall` that apps export from a federated `./lifecycle` module; the shell invokes them best-effort.
|
|
8
|
+
- **Standalone-dev mock** — `createMockShell` for running an app outside the shell.
|
|
9
|
+
- **Shell-side installer** — `@rise-x/apps-sdk/shell` exposes `installShellBridge` for the host to wire the bridge.
|
|
10
|
+
- **Scaffolder CLI** — `npx @rise-x/apps-sdk init <name>` to create a new app in the current directory.
|
|
11
|
+
|
|
12
|
+
## Quick start (scaffold)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx @rise-x/apps-sdk init my-thing
|
|
16
|
+
cd my-thing
|
|
17
|
+
pnpm start
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### CLI flags
|
|
21
|
+
|
|
22
|
+
| Flag | Default | Meaning |
|
|
23
|
+
| --- | --- | --- |
|
|
24
|
+
| `--pm=<npm\|yarn\|pnpm>` | auto-detected | package manager used for `install` |
|
|
25
|
+
| `--port=<n>` | `5101` | webpack dev-server port in the generated app |
|
|
26
|
+
| `--skip-install` | off | skip `<pm> install` after scaffolding |
|
|
27
|
+
| `--json` | off | emit `{ path, slug, scope, pkgName, port, pm }` on stdout |
|
|
28
|
+
|
|
29
|
+
## Design assets (static HTML mocks)
|
|
30
|
+
|
|
31
|
+
The package ships what an agent needs to build **static single-file HTML
|
|
32
|
+
design mocks** without repo access:
|
|
33
|
+
|
|
34
|
+
- `build/ui/styles.css` — the compiled design-system stylesheet, **Inter font
|
|
35
|
+
embedded** — inline it into the mock.
|
|
36
|
+
- `build/ui/reference/` — the design-system component sources (read-only
|
|
37
|
+
reference for markup, class strings, and variant APIs).
|
|
38
|
+
- `template/src/App.tsx` — the canonical app layout (left-rail chrome +
|
|
39
|
+
screens); scaffolded apps start from it, and design mocks follow the same
|
|
40
|
+
composition.
|
|
41
|
+
|
|
42
|
+
## Use in app code
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import {
|
|
46
|
+
useShellUser,
|
|
47
|
+
useShellEnvironment,
|
|
48
|
+
useShellNavigate,
|
|
49
|
+
getShellApiV4,
|
|
50
|
+
} from '@rise-x/apps-sdk';
|
|
51
|
+
|
|
52
|
+
const user = useShellUser();
|
|
53
|
+
const env = useShellEnvironment();
|
|
54
|
+
const navigate = useShellNavigate();
|
|
55
|
+
const apps = getShellApiV4('apps');
|
|
56
|
+
const work = getShellApiV4('work');
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### UI components (`@rise-x/apps-sdk/ui`)
|
|
60
|
+
|
|
61
|
+
The Rise-X design system (shadcn components on the shell's Tailwind theme) is
|
|
62
|
+
re-exported for apps:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { Button, Dialog, DialogContent, Input, cn } from '@rise-x/apps-sdk/ui';
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
How it works: the SDK ships the **typings**; the **runtime** is the shell's own
|
|
69
|
+
copy of `@rise-x/ui`, delivered through the Module Federation share scope —
|
|
70
|
+
exactly how apps already consume React. That is deliberate: the components are
|
|
71
|
+
styled by the shell's compiled Tailwind CSS, so only the shell's copy renders
|
|
72
|
+
correctly, and there is never a second React/component instance.
|
|
73
|
+
|
|
74
|
+
Requirements in the app:
|
|
75
|
+
|
|
76
|
+
1. `webpack.config.js` must list it in `shared` (the template already does):
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
'@rise-x/ui': { singleton: true, requiredVersion: false, import: false },
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. Federated, components render from the shell's copy. The standalone dev
|
|
83
|
+
config (`webpack.local.config.js`) aliases `@rise-x/ui` to the SDK's own
|
|
84
|
+
compiled bundle (`./ui/standalone`) instead — a self-contained snapshot
|
|
85
|
+
with its CSS self-injected, so components render for real with no shell.
|
|
86
|
+
It's a snapshot, not the source of truth: verify in a host (or deployed)
|
|
87
|
+
before release.
|
|
88
|
+
|
|
89
|
+
#### `MapView`
|
|
90
|
+
|
|
91
|
+
The one component with a real library behind it. It renders a Leaflet basemap
|
|
92
|
+
and nothing else — markers, routes and heat layers are yours to add. Leaflet is
|
|
93
|
+
fetched in its own chunk on first mount, so apps that never show a map pay
|
|
94
|
+
nothing for it.
|
|
95
|
+
|
|
96
|
+
`onReady` hands back the map **and the Leaflet module it was built from**. Build
|
|
97
|
+
layers off that `L`: the app then needs no `leaflet` dependency of its own, and
|
|
98
|
+
a second copy of the library never meets the first one at `map.addLayer`.
|
|
99
|
+
|
|
100
|
+
Leaflet's own chrome is restyled to the kit — the zoom cluster is a grouped
|
|
101
|
+
ghost control, tooltips match `TooltipContent`, popups match `PopoverContent`,
|
|
102
|
+
and markers are the design system's ringed pin rather than Leaflet's blue PNG.
|
|
103
|
+
All of it reads from the theme tokens, so it follows dark mode and an ecosystem
|
|
104
|
+
rebrand without any work in the app. Tiles default to `tiles="auto"`, which
|
|
105
|
+
switches between the light and dark basemap live with the shell's theme.
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { MapView, mapPin } from '@rise-x/apps-sdk/ui';
|
|
109
|
+
|
|
110
|
+
<MapView
|
|
111
|
+
center={[51.92, 4.48]}
|
|
112
|
+
zoom={9}
|
|
113
|
+
className="h-[320px] rounded-lg border border-border"
|
|
114
|
+
onReady={(map, L) => {
|
|
115
|
+
// Already the branded pin — no icon needed.
|
|
116
|
+
L.marker([51.92, 4.48]).addTo(map).bindTooltip('Rotterdam');
|
|
117
|
+
// tone: 'brand' | 'success' | 'warning' | 'error' | 'info'
|
|
118
|
+
L.marker([52.01, 4.36], { icon: L.divIcon(mapPin({ tone: 'error' })) }).addTo(map);
|
|
119
|
+
}}
|
|
120
|
+
/>;
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`tiles` also takes a preset (`'light'`, `'dark'`, `'streets'`, `'satellite'`), a
|
|
124
|
+
custom tile layer, or `null` for no basemap at all.
|
|
125
|
+
|
|
126
|
+
`center`/`zoom`/`bounds` set the **initial** view only — pan and zoom afterwards
|
|
127
|
+
through the instance (`map.flyTo(...)`), so a re-render never yanks the map away
|
|
128
|
+
from someone who is using it. The map fills its parent and re-fits itself
|
|
129
|
+
whenever the box changes size, so it can sit in a panel, a split or a tab
|
|
130
|
+
without the usual grey gutters. `interactive={false}` gives a static preview for
|
|
131
|
+
cards and list rows, and children render over the map as overlays.
|
|
132
|
+
|
|
133
|
+
### Lifecycle hooks
|
|
134
|
+
|
|
135
|
+
Expose a `./lifecycle` module from your app's webpack `ModuleFederationPlugin` and export any subset of the three hooks:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
// src/lifecycle.ts
|
|
139
|
+
import type { InstallHook, UninstallHook, UpdateHook } from '@rise-x/apps-sdk';
|
|
140
|
+
import localforage from 'localforage';
|
|
141
|
+
|
|
142
|
+
export const onInstall: InstallHook = async ({ manifest, user, environment }) => {
|
|
143
|
+
// first time this device sees the app — pre-warm caches, seed defaults, etc.
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const onUpdate: UpdateHook = async (ctx, { from, to }) => {
|
|
147
|
+
// version bumped in the registry — run migrations if needed.
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const onUninstall: UninstallHook = async ({ manifest }) => {
|
|
151
|
+
// drop whatever the app persisted
|
|
152
|
+
await localforage.dropInstance({ name: `diana-app-${manifest.id}` });
|
|
153
|
+
};
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
// webpack.config.js
|
|
158
|
+
new ModuleFederationPlugin({
|
|
159
|
+
exposes: {
|
|
160
|
+
'./App': './src/App',
|
|
161
|
+
'./lifecycle': './src/lifecycle',
|
|
162
|
+
},
|
|
163
|
+
// ...
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The shell invokes hooks best-effort: errors are logged, 10s timeout per hook, missing hooks skip silently. Hooks run inside the shell's page — `getShellApi()` / `getShellApiV4()` work from inside them.
|
|
168
|
+
|
|
169
|
+
### Storage
|
|
170
|
+
|
|
171
|
+
Bring your own — install `localforage` (or IndexedDB, Cache API, etc.) as a direct dep. Put cleanup in `onUninstall`.
|
|
172
|
+
|
|
173
|
+
## Connectors
|
|
174
|
+
|
|
175
|
+
`@rise-x/apps-sdk/connectors` wraps the raw clients with typed, framework-agnostic
|
|
176
|
+
helpers. Prefer them over hand-rolled `getShellApi*` calls; fall back to the raw
|
|
177
|
+
clients only for endpoints the connectors don't cover.
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
import { flows, work, assets, agents, ConnectorError } from '@rise-x/apps-sdk/connectors';
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Flows — discovery
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
// Prefer ids over names: displayName is user-editable and name changes when a
|
|
187
|
+
// flow is rebuilt, so hardcoded name strings silently break later. Bake the
|
|
188
|
+
// flowOriginId into app config instead:
|
|
189
|
+
const FLOW_ORIGIN_ID = '7732039e-6c5e-4bca-9a23-3bb67b1a1b22';
|
|
190
|
+
const flow = await flows.get(FLOW_ORIGIN_ID); // flow + full step tree (merged)
|
|
191
|
+
// get/getConfig accept a concrete flow id or a flowOriginId — either
|
|
192
|
+
// resolves to the latest published version (steps and config included).
|
|
193
|
+
const config = await flows.getConfig(flow.id); // v4 step/task/layout grouping + nameMap
|
|
194
|
+
const layout = await flows.getLayout(config.steps[0].tasks[0].layoutId!);
|
|
195
|
+
const fields = flows.flattenLayoutFields(layout); // leaf form fields with data paths
|
|
196
|
+
|
|
197
|
+
// findTask/list's name-matching is for dev-time exploration or a user-facing
|
|
198
|
+
// search box, not for a shipped id — displayName isn't a stable reference:
|
|
199
|
+
const summaries = await flows.list({ search: 'risk' }); // statuses default ['Active']
|
|
200
|
+
const hit = await flows.findTask({ flow: 'Risk Management', task: 'Submit Risk' });
|
|
201
|
+
if (hit) console.log(hit.task.id, hit.step.displayName);
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Work — items (read + write)
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
// Create a work item by starting a flow (flow.id or a bare flowOriginId —
|
|
208
|
+
// the platform resolves either to the latest published version).
|
|
209
|
+
const created = await work.start({ flowId: flow.id, data: { title: 'New risk' } });
|
|
210
|
+
|
|
211
|
+
// Connect to it.
|
|
212
|
+
const detail = await work.get(created.id);
|
|
213
|
+
const data = await work.getData(created.id, { path: '$.identifyPotentialRisk' });
|
|
214
|
+
|
|
215
|
+
// Update work data (operations: Set | Push | Pull | Unset | AddToSet | Merge).
|
|
216
|
+
await work.patchData(created.id, {
|
|
217
|
+
originId: detail.flowOriginId!,
|
|
218
|
+
path: '$.identifyPotentialRisk.riskDescription',
|
|
219
|
+
value: 'Updated from an app',
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// Complete a task action. Patch data first — submit does not merge data.
|
|
223
|
+
const action = detail.actions[0];
|
|
224
|
+
const actionName = action?.eventName ?? action?.name;
|
|
225
|
+
if (!actionName) throw new Error('work item has no available action');
|
|
226
|
+
await work.submit({ workId: created.id, actionName });
|
|
227
|
+
|
|
228
|
+
// Remove a work item (no server-side undo).
|
|
229
|
+
await work.delete(created.id);
|
|
230
|
+
|
|
231
|
+
// Paginated listing — `properties` shapes each row's `data` subtree.
|
|
232
|
+
// Unlike start()/get()/getConfig(), listing filters STRICTLY by flowOriginId —
|
|
233
|
+
// a concrete flow id here silently returns an empty page, not an error.
|
|
234
|
+
for await (const row of work.iterate({
|
|
235
|
+
flow, // object from flows.list()/get(), or a bare flowOriginId string
|
|
236
|
+
properties: { riskLevel: '$.assessRiskByRiskCustodian.governingRiskLevel' },
|
|
237
|
+
maxItems: 200,
|
|
238
|
+
})) {
|
|
239
|
+
console.log(row.displayName, row.data?.riskLevel);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const audit = await work.getAudit(created.id);
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Assets — typed records
|
|
246
|
+
|
|
247
|
+
Assets ("entities"/"things" in platform parlance) are typed records defined by
|
|
248
|
+
an entity flow — the flow's origin id is the asset-type reference:
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
const types = await assets.types(); // asset types in the current ecosystem
|
|
252
|
+
const supplier = types.find((t) => t.entityType === 'Supplier')!;
|
|
253
|
+
|
|
254
|
+
// Server-side free-text search within a type.
|
|
255
|
+
const hits = await assets.search({ type: 'Supplier', search: 'acme', dataPaths: ['$.name'] });
|
|
256
|
+
|
|
257
|
+
// Full detail: data document, relationships, edit draft, permissions flags.
|
|
258
|
+
const detail = await assets.get(hits[0].id);
|
|
259
|
+
|
|
260
|
+
// Paginated listing — same `properties` data-shaping as work.iterate.
|
|
261
|
+
for await (const row of assets.iterate({ type: supplier, properties: { rating: '$.supplier.rating' } })) {
|
|
262
|
+
console.log(row.displayName, row.data?.rating);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Follow flow-configured relationships (targets default to assets; pass
|
|
266
|
+
// targetDataType: ASSET_TARGET_DATA_TYPES.work for related work items).
|
|
267
|
+
const related = await assets.listRelated({ assetId: detail.id, relationships: ['contracts'] });
|
|
268
|
+
|
|
269
|
+
// Create/edit go through a draft work item (the platform's edit model):
|
|
270
|
+
// fill it with work.patchData(), save it with work.submit().
|
|
271
|
+
const draft = await assets.create({ type: supplier });
|
|
272
|
+
await work.patchData(draft.id, { originId: draft.flowOriginId!, path: '$.supplier.name', value: 'Acme' });
|
|
273
|
+
const submitAction = draft.actions[0];
|
|
274
|
+
await work.submit({ workId: draft.id, actionName: submitAction.eventName ?? submitAction.name! });
|
|
275
|
+
|
|
276
|
+
const editDraft = await assets.startEdit({ assetId: detail.id, flowOriginId: detail.flowOriginId! });
|
|
277
|
+
await assets.clone(detail.id);
|
|
278
|
+
await assets.delete(detail.id);
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Agents — configurable AI
|
|
282
|
+
|
|
283
|
+
CRUD over the agent config registry (`/api/v4/config/agent`, rise-x-api) plus
|
|
284
|
+
streaming runs through the rise-x-ai gateway:
|
|
285
|
+
|
|
286
|
+
```ts
|
|
287
|
+
const { items } = await agents.list({ search: 'support' });
|
|
288
|
+
const agent = await agents.create({
|
|
289
|
+
name: 'Platform Helper',
|
|
290
|
+
model: 'gpt-5',
|
|
291
|
+
systemPrompt: 'You help operators work with Rise-X flows.',
|
|
292
|
+
mcpServers: [
|
|
293
|
+
{
|
|
294
|
+
name: 'rise-x',
|
|
295
|
+
url: 'https://mcp.rise-x.io/mcp',
|
|
296
|
+
transport: 'Http',
|
|
297
|
+
authType: 'CallerToken', // runtime forwards the signed-in user's JWT
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// Streaming a reply — the easy path. streamAgentReply() runs the loop AND the
|
|
303
|
+
// delta accumulation for you and yields a ready-to-render snapshot each time
|
|
304
|
+
// the text grows, an error arrives, or the stream ends. Wrap either agents.run
|
|
305
|
+
// or chat.send.
|
|
306
|
+
import { streamAgentReply, collectAgentReply } from '@rise-x/apps-sdk/connectors';
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
for await (const s of streamAgentReply(
|
|
310
|
+
agents.run({ agentId: agent.id, message: 'Open risks?', useHistory: false }),
|
|
311
|
+
)) {
|
|
312
|
+
setReply(s.text); // already accumulated — just render it
|
|
313
|
+
// Report once, when the stream ends: the agent's error message if there was
|
|
314
|
+
// one, otherwise a non-COMPLETED terminal reason.
|
|
315
|
+
if (s.done) {
|
|
316
|
+
if (s.error) showError(s.error);
|
|
317
|
+
else if (s.reason !== 'COMPLETED') showError(`run ended: ${s.reason}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
} catch (err) {
|
|
321
|
+
// Transport / HTTP / abort failures (e.g. the AI gateway being down) THROW —
|
|
322
|
+
// they are not delivered as s.error. Catch them here.
|
|
323
|
+
showError(String(err)); // ConnectorError, e.g. code 'AI_UNAVAILABLE'
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Not streaming the UI? Await the whole answer in one call. Same rule: mid-stream
|
|
327
|
+
// agent errors come back as `error`; transport/abort failures throw — so catch.
|
|
328
|
+
try {
|
|
329
|
+
const { text, reason, error } = await collectAgentReply(
|
|
330
|
+
agents.run({ agentId: agent.id, message: 'Open risks?', useHistory: false }),
|
|
331
|
+
);
|
|
332
|
+
} catch (err) {
|
|
333
|
+
showError(String(err));
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Multi-turn chat — memory is server-persisted in Mongo (ZDR-safe, no OpenAI
|
|
337
|
+
// retention cliff). createChat() captures the chat_id from the first turn's
|
|
338
|
+
// end_of_stream and passes it back on every subsequent send().
|
|
339
|
+
const chat = agents.createChat({ agentId: agent.id });
|
|
340
|
+
for await (const s of streamAgentReply(chat.send('Summarize the open risks'))) setReply(s.text);
|
|
341
|
+
for await (const s of streamAgentReply(chat.send('Now only the high-severity ones'))) setReply(s.text); // remembers
|
|
342
|
+
const chatId = chat.chatId; // stable server id — persist it to reopen later
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Chats are listable, reopenable, renamable, and deletable — the transcript
|
|
346
|
+
(including tool-call items) is owned by the platform and read back for replay:
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
// List the signed-in user's chats (newest first), optionally per agent.
|
|
350
|
+
const { items } = await agents.listChats({ agentId: agent.id });
|
|
351
|
+
const one = await agents.getChat(items[0].id);
|
|
352
|
+
|
|
353
|
+
// Reopen a stored chat and continue it — memory is carried server-side.
|
|
354
|
+
const resumed = agents.createChat({ agentId: agent.id, chatId: one.id });
|
|
355
|
+
for await (const s of streamAgentReply(resumed.send('and the medium ones?'))) setReply(s.text);
|
|
356
|
+
|
|
357
|
+
// Render the full transcript (paged by seq; tool calls included).
|
|
358
|
+
const page = await agents.getChatMessages(one.id, { pageSize: 50 });
|
|
359
|
+
for (const m of page.items) renderMessage(m); // m.itemType: 'Message' | 'ToolCall' | 'ToolResult' | 'Reasoning'
|
|
360
|
+
// page.nextSeq → pass as fromSeq to page forward.
|
|
361
|
+
|
|
362
|
+
await agents.renameChat(one.id, 'Q3 risk review');
|
|
363
|
+
await agents.deleteChat(one.id); // removes the chat and its messages
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Notes:
|
|
367
|
+
|
|
368
|
+
- **Streaming contract.** `agents.run`/`chat.send` yield raw `AgentRunEvent`s
|
|
369
|
+
where assistant text arrives as `agent_event` frames (`event_type: 'MESSAGE'`)
|
|
370
|
+
whose `text` is a per-token **delta**, never the cumulative string. Prefer
|
|
371
|
+
`streamAgentReply()` (yields accumulated `AgentReplyState` snapshots) or
|
|
372
|
+
`collectAgentReply()` (awaits the final state) so you never hand-roll that
|
|
373
|
+
accumulation. For finer control, the frame readers `agentMessageText` /
|
|
374
|
+
`agentEndReason` / `agentErrorText` decode a single event, and the typed views
|
|
375
|
+
(`AgentEventData`, `AgentEndData`, `AgentErrorData`) are exported for reasoning
|
|
376
|
+
/ tool-call / handoff frames.
|
|
377
|
+
- `agents.run`/`createChat` need shell bridge **v3** (`getAi`) and a deployment
|
|
378
|
+
with `DIANA_AI_API_ENDPOINT` configured — otherwise they throw
|
|
379
|
+
`ConnectorError('SHELL_TOO_OLD' | 'AI_UNAVAILABLE')`.
|
|
380
|
+
- Memory contract: clients only ever handle `chatId`. `useHistory` defaults to
|
|
381
|
+
`true`; `useHistory:false` runs one-shot and persists nothing. Passing a
|
|
382
|
+
`chatId` together with `useHistory:false` is illegal → `INVALID_ARG` (mirrors
|
|
383
|
+
the gateway's 400) and makes no network call.
|
|
384
|
+
- `listChats`/`getChat`/`renameChat`/`deleteChat`/`getChatMessages` hit the
|
|
385
|
+
server chat store via the same `config` v4 client (`/api/v4/ai/agent-chat`).
|
|
386
|
+
- Stored MCP `apiKey`s are redacted to `"***"` on read; `agents.update()` strips
|
|
387
|
+
the sentinel so read-modify-write can't clobber the stored secret.
|
|
388
|
+
|
|
389
|
+
### Errors
|
|
390
|
+
|
|
391
|
+
Every connector failure is normalized to `ConnectorError` with a `code`:
|
|
392
|
+
|
|
393
|
+
| Code | Meaning |
|
|
394
|
+
| --- | --- |
|
|
395
|
+
| `SHELL_UNAVAILABLE` | not running inside the shell (or the standalone mock has no `api`/`apiV4` handler) |
|
|
396
|
+
| `SHELL_TOO_OLD` | host bridge predates a required capability (e.g. `getAi`) |
|
|
397
|
+
| `AI_UNAVAILABLE` | shell present but no AI gateway configured |
|
|
398
|
+
| `HTTP_ERROR` / `NOT_FOUND` | non-2xx response (`status` populated) |
|
|
399
|
+
| `NETWORK_ERROR` | request never got a response |
|
|
400
|
+
| `ABORTED` | `AbortSignal` fired |
|
|
401
|
+
| `PARSE_ERROR` | malformed SSE/JSON payload |
|
|
402
|
+
| `INVALID_ARG` | caller-supplied argument can't be used, no request was made (e.g. an `AssetType` without a defining flow) |
|
|
403
|
+
|
|
404
|
+
### Standalone dev
|
|
405
|
+
|
|
406
|
+
The default mock shell throws on API access. Point it at a backend to use
|
|
407
|
+
connectors outside the shell:
|
|
408
|
+
|
|
409
|
+
```ts
|
|
410
|
+
import axios from 'axios';
|
|
411
|
+
import { createMockShell } from '@rise-x/apps-sdk';
|
|
412
|
+
|
|
413
|
+
const devAxios = axios.create({
|
|
414
|
+
baseURL: 'http://localhost:50061',
|
|
415
|
+
headers: { Authorization: token, Environment: 'dev' },
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
window.__DIANA_SHELL__ = createMockShell({
|
|
419
|
+
api: () => devAxios,
|
|
420
|
+
apiV4: (_name) => devAxios, // one dev backend serves every V4ApiKey
|
|
421
|
+
ai: { baseUrl: 'http://localhost:50062', getHeaders: () => ({ Authorization: token, Ecosystem: 'dev' }) },
|
|
422
|
+
});
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
## Query layer (react-query)
|
|
426
|
+
|
|
427
|
+
`@rise-x/apps-sdk/query` wraps the connectors in a
|
|
428
|
+
[@tanstack/react-query](https://tanstack.com/query) v5 layer: request dedupe,
|
|
429
|
+
caching, background refetch, and cancellation for free. react-query is an
|
|
430
|
+
**optional peer** — apps that never import `/query` don't need it installed.
|
|
431
|
+
|
|
432
|
+
```tsx
|
|
433
|
+
import { useFlows, useWorkRows, useSubmitWork, dedupeRows } from '@rise-x/apps-sdk/query';
|
|
434
|
+
|
|
435
|
+
function MyPanel({ flowOriginId }: { flowOriginId: string }) {
|
|
436
|
+
const { data: flows, error, isFetching } = useFlows();
|
|
437
|
+
const rows = useWorkRows({ flow: flowOriginId, pageSize: 50 });
|
|
438
|
+
const submit = useSubmitWork(); // invalidates the right caches on success
|
|
439
|
+
|
|
440
|
+
const items = dedupeRows(rows.data); // flatten infinite pages, drop repeats
|
|
441
|
+
// …
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**Zero config — do not mount a provider.** The hooks resolve their
|
|
446
|
+
`QueryClient` from React context: federated apps get a **per-app client the
|
|
447
|
+
shell mounts** around them (isolated from the shell's own persisted cache and
|
|
448
|
+
from other apps), and everywhere else — standalone dev, older shells — the
|
|
449
|
+
hooks fall back to a per-bundle client automatically. The one requirement: the
|
|
450
|
+
app's webpack config must share react-query so the shell's context can cross
|
|
451
|
+
the federation boundary (the scaffold already does this):
|
|
452
|
+
|
|
453
|
+
```js
|
|
454
|
+
shared: {
|
|
455
|
+
// keep the bundled fallback (no `import: false`) — see the scaffold comment
|
|
456
|
+
'@tanstack/react-query': { singleton: true, requiredVersion: '^5.0.0' },
|
|
457
|
+
}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Read hooks (all take an optional trailing `SdkQueryOptions` — `enabled`,
|
|
461
|
+
`staleTime`, `retry`, …):
|
|
462
|
+
|
|
463
|
+
| Domain | Hooks |
|
|
464
|
+
| --- | --- |
|
|
465
|
+
| flows | `useFlows`, `useFlow`, `useFlowConfig`, `useFlowLayout`, `useFlowTask` |
|
|
466
|
+
| work | `useWork`, `useWorkData`, `useWorkRows` *(infinite)*, `useRelatedWork`, `useWorkAudit` |
|
|
467
|
+
| assets | `useAssetTypes`, `useAsset`, `useAssetSearch`, `useAssetRows` *(infinite)*, `useRelatedAssets` |
|
|
468
|
+
| agents | `useAgents`, `useAgent`, `useAgentChats`, `useAgentChat`, `useAgentChatMessages` |
|
|
469
|
+
|
|
470
|
+
Mutation hooks compose your `onSuccess` with built-in invalidation (e.g.
|
|
471
|
+
`useSubmitWork` refreshes the work detail/data/audit, row listings, and asset
|
|
472
|
+
scope): `useStartWork`, `usePatchWorkData`, `useSubmitWork`, `useDeleteWork`,
|
|
473
|
+
`useCreateAsset`, `useStartEditAsset`, `useCloneAsset`, `useDeleteAsset`,
|
|
474
|
+
`useCreateAgent`, `useUpdateAgent`, `useDeleteAgent`, `useRenameAgentChat`,
|
|
475
|
+
`useDeleteAgentChat`.
|
|
476
|
+
|
|
477
|
+
Details worth knowing:
|
|
478
|
+
|
|
479
|
+
- **Keys are environment-scoped.** Every key is
|
|
480
|
+
`['rise-apps-sdk', envId, …]` — switching ecosystem refetches automatically
|
|
481
|
+
and the old environment's entries age out. `queryKeys` is exported for
|
|
482
|
+
targeted manual invalidation with the exact shapes the hooks use.
|
|
483
|
+
- **Defaults**: `staleTime` 30 s, `gcTime` 5 min, no refetch-on-focus, up to 2
|
|
484
|
+
retries that skip terminal `ConnectorError` codes (4xx, `NOT_FOUND`,
|
|
485
|
+
`ABORTED`, …). Override per call or via `createAppQueryClient(overrides)`.
|
|
486
|
+
- **Errors are `ConnectorError`** — `error.code` narrows exactly like the
|
|
487
|
+
connector table above.
|
|
488
|
+
- **Full react-query power** (select, suspense, prefetch): use the
|
|
489
|
+
queryOptions factories directly — `useQuery(flowQueries.list(args))`,
|
|
490
|
+
`queryClient.prefetchQuery(workQueries.detail(id))`. `useAppQueryClient()`
|
|
491
|
+
returns the same client the hooks use.
|
|
492
|
+
- **Raw connector writes bypass the invalidation map** — after one, call
|
|
493
|
+
`invalidateAppSdkQueries(useAppQueryClient())`.
|
|
494
|
+
- **Out of scope**: the async iterators (`work.iterate`/`assets.iterate` —
|
|
495
|
+
use the infinite hooks instead) and the SSE streams (`agents.run`,
|
|
496
|
+
chat `send`) stay on the connectors.
|
|
497
|
+
|
|
498
|
+
## Shell-side (host) wiring
|
|
499
|
+
|
|
500
|
+
```ts
|
|
501
|
+
import { axios } from '@diana/core';
|
|
502
|
+
import { installShellBridge } from '@rise-x/apps-sdk/shell';
|
|
503
|
+
|
|
504
|
+
installShellBridge({
|
|
505
|
+
getApi: () => axios.api(),
|
|
506
|
+
getApiV4: (name) => axios.apiV4(name),
|
|
507
|
+
});
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
`getApiV4` takes a `V4ApiKey` (`'apps' | 'work' | 'config' | 'attachment'`) — guests
|
|
511
|
+
choose which named v4 instance they want and the host forwards the key to
|
|
512
|
+
`@diana/core`'s `axios.apiV4(key)`. The host must register every key it intends to
|
|
513
|
+
expose via `setupApiV4(key, { baseURL })` before installing the bridge.
|
|
514
|
+
|
|
515
|
+
`ShellBridgeKeeper` (React component in the shell) pushes the current user, environment,
|
|
516
|
+
and router `navigate` into the bridge via `getMutableShell` — also exported from
|
|
517
|
+
`@rise-x/apps-sdk/shell`.
|
|
518
|
+
|
|
519
|
+
The shell's `RemoteAppLoader` additionally wraps every mounted app in a
|
|
520
|
+
per-app `QueryClient` (built with `createAppQueryClient` from
|
|
521
|
+
`@rise-x/apps-sdk/query`), which is what the SDK's query hooks pick up
|
|
522
|
+
through context in federated apps.
|
|
523
|
+
|
|
524
|
+
## Local development against the SDK
|
|
525
|
+
|
|
526
|
+
In-repo consumers (ClientApp, apps/\*) declare `"@rise-x/apps-sdk": "workspace:*"`,
|
|
527
|
+
so pnpm links them straight to `packages/apps-sdk` — no publish or link step.
|
|
528
|
+
|
|
529
|
+
Live loop (rebuilds `build/` on save; consumers pick it up on their next compile):
|
|
530
|
+
|
|
531
|
+
```bash
|
|
532
|
+
cd packages/apps-sdk && pnpm start:package
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
For an app developed *outside* this repo, install the published SDK package:
|
|
536
|
+
|
|
537
|
+
```bash
|
|
538
|
+
pnpm add @rise-x/apps-sdk
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
## Publishing
|
|
542
|
+
|
|
543
|
+
Publishes to the public npm registry (`registry.npmjs.org`) under the `rise-x` org, per `publishConfig` in `package.json`. CI publishes automatically when `packages/apps-sdk/**` changes land on `main` and the version in `package.json` is not yet on the registry (`.github/workflows/publish-apps-sdk.yml`).
|
|
544
|
+
|
|
545
|
+
To publish manually you need an npmjs account with publish rights in the `rise-x` org (`npm login`), then:
|
|
546
|
+
|
|
547
|
+
```bash
|
|
548
|
+
pnpm publish --no-git-checks
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
The `prepack` hook builds `@rise-x/ui` and the package automatically — no need to build first. The registry and public access come from `publishConfig`, not CLI flags.
|
|
552
|
+
|
|
553
|
+
`template/` is included via the `files` array so `npx @rise-x/apps-sdk init` works from the registry version.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireShell = requireShell;
|
|
4
|
+
const errors_1 = require("./connectors/errors");
|
|
5
|
+
const shellBridge_1 = require("./shellBridge");
|
|
6
|
+
let versionMismatchWarned = false;
|
|
7
|
+
function requireShell() {
|
|
8
|
+
const shell = window.__DIANA_SHELL__;
|
|
9
|
+
if (!shell) {
|
|
10
|
+
// ConnectorError so toConnectorError passes this through as
|
|
11
|
+
// SHELL_UNAVAILABLE instead of degrading it to NETWORK_ERROR.
|
|
12
|
+
throw new errors_1.ConnectorError("SHELL_UNAVAILABLE", "[@rise-x/apps-sdk] window.__DIANA_SHELL__ is missing. The app must run inside the Rise-X shell.");
|
|
13
|
+
}
|
|
14
|
+
// Surface bridge version drift once per session. e.g. a v1 app running under a
|
|
15
|
+
// v2 host calls getApiV4() with no arg and would otherwise fail opaquely.
|
|
16
|
+
if (!versionMismatchWarned && shell.version !== shellBridge_1.SHELL_BRIDGE_VERSION) {
|
|
17
|
+
versionMismatchWarned = true;
|
|
18
|
+
console.warn(`[@rise-x/apps-sdk] shell bridge version mismatch: host provides v${shell.version}, ` +
|
|
19
|
+
`this app was built against v${shellBridge_1.SHELL_BRIDGE_VERSION}. The bridge API may be ` +
|
|
20
|
+
`incompatible (e.g. getApiV4 takes a V4ApiKey argument since v2, getAi exists since v3).`);
|
|
21
|
+
}
|
|
22
|
+
return shell;
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AxiosInstance } from "axios";
|
|
2
|
+
import type { DianaShell, ShellAiApi, ShellEnvironment, ShellUser, V4ApiKey } from "./shellBridge";
|
|
3
|
+
export declare function getShellApi(): AxiosInstance;
|
|
4
|
+
export declare function getShellApiV4(name: V4ApiKey): AxiosInstance;
|
|
5
|
+
export declare function getShell(): DianaShell | null;
|
|
6
|
+
export declare function getShellUser(): ShellUser | null;
|
|
7
|
+
export declare function getShellAi(): ShellAiApi | null;
|
|
8
|
+
export declare function getShellEnvironment(): ShellEnvironment | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getShellApi = getShellApi;
|
|
4
|
+
exports.getShellApiV4 = getShellApiV4;
|
|
5
|
+
exports.getShell = getShell;
|
|
6
|
+
exports.getShellUser = getShellUser;
|
|
7
|
+
exports.getShellAi = getShellAi;
|
|
8
|
+
exports.getShellEnvironment = getShellEnvironment;
|
|
9
|
+
const _internal_1 = require("./_internal");
|
|
10
|
+
function getShellApi() {
|
|
11
|
+
return (0, _internal_1.requireShell)().getApi();
|
|
12
|
+
}
|
|
13
|
+
function getShellApiV4(name) {
|
|
14
|
+
return (0, _internal_1.requireShell)().getApiV4(name);
|
|
15
|
+
}
|
|
16
|
+
// Read-only view of the shell bridge. NOTE: this returns the *live* bridge
|
|
17
|
+
// object, not a copy or frozen proxy — the read-only contract is enforced only
|
|
18
|
+
// by the DianaShell type (mutators are intentionally absent from it). Apps must
|
|
19
|
+
// not cast back to MutableShell. Returns null when the shell hasn't installed
|
|
20
|
+
// itself yet (e.g. early startup, or standalone dev before the mock is set up).
|
|
21
|
+
// For mutator access (bridge installer/keeper only), use `getMutableShell` from
|
|
22
|
+
// `@rise-x/apps-sdk/shell`.
|
|
23
|
+
function getShell() {
|
|
24
|
+
return window.__DIANA_SHELL__ ?? null;
|
|
25
|
+
}
|
|
26
|
+
function getShellUser() {
|
|
27
|
+
return getShell()?.getUser() ?? null;
|
|
28
|
+
}
|
|
29
|
+
// Handle to the rise-x-ai gateway, or null when the shell is missing, predates
|
|
30
|
+
// bridge v3 (no getAi), or has no AI gateway configured. Feature-detected so a
|
|
31
|
+
// v3-built app degrades cleanly on a v2 host instead of TypeError-ing.
|
|
32
|
+
function getShellAi() {
|
|
33
|
+
const shell = getShell();
|
|
34
|
+
if (!shell || typeof shell.getAi !== "function")
|
|
35
|
+
return null;
|
|
36
|
+
return shell.getAi();
|
|
37
|
+
}
|
|
38
|
+
function getShellEnvironment() {
|
|
39
|
+
return getShell()?.getEnvironment() ?? null;
|
|
40
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
declare function parseCli(): {
|
|
3
|
+
values: {
|
|
4
|
+
pm: string | undefined;
|
|
5
|
+
port: string | undefined;
|
|
6
|
+
"skip-install": boolean | undefined;
|
|
7
|
+
json: boolean | undefined;
|
|
8
|
+
help: boolean | undefined;
|
|
9
|
+
};
|
|
10
|
+
positionals: string[];
|
|
11
|
+
};
|
|
12
|
+
export type CliFlags = ReturnType<typeof parseCli>["values"];
|
|
13
|
+
export {};
|