@rise-x/apps-sdk 0.11.0 → 0.15.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.
Files changed (83) hide show
  1. package/README.md +904 -20
  2. package/build/_internal.d.ts +4 -1
  3. package/build/_internal.js +67 -0
  4. package/build/cli/index.d.ts +7 -1
  5. package/build/cli/index.js +68 -14
  6. package/build/cli/scan.d.ts +60 -0
  7. package/build/cli/scan.js +725 -0
  8. package/build/cli/validate.d.ts +33 -0
  9. package/build/cli/validate.js +169 -0
  10. package/build/connectors/agents.d.ts +10 -6
  11. package/build/connectors/agents.js +59 -44
  12. package/build/connectors/attachments.d.ts +51 -0
  13. package/build/connectors/attachments.js +76 -0
  14. package/build/connectors/errors.js +24 -0
  15. package/build/connectors/flows.d.ts +13 -2
  16. package/build/connectors/flows.js +64 -19
  17. package/build/connectors/index.d.ts +5 -1
  18. package/build/connectors/index.js +14 -2
  19. package/build/connectors/integrations.d.ts +29 -0
  20. package/build/connectors/integrations.js +32 -0
  21. package/build/connectors/offline.d.ts +34 -0
  22. package/build/connectors/offline.js +135 -0
  23. package/build/connectors/readPolicy.d.ts +29 -0
  24. package/build/connectors/readPolicy.js +105 -0
  25. package/build/connectors/types.d.ts +75 -0
  26. package/build/connectors/types.js +128 -0
  27. package/build/connectors/vectorStores.d.ts +45 -0
  28. package/build/connectors/vectorStores.js +199 -0
  29. package/build/connectors/work.d.ts +14 -2
  30. package/build/connectors/work.js +43 -19
  31. package/build/dependencies/bound.d.ts +87 -0
  32. package/build/dependencies/bound.js +207 -0
  33. package/build/dependencies/index.d.ts +2 -0
  34. package/build/dependencies/index.js +13 -0
  35. package/build/dependencyRegistry.d.ts +15 -0
  36. package/build/dependencyRegistry.js +28 -0
  37. package/build/index.d.ts +2 -1
  38. package/build/index.js +12 -1
  39. package/build/lifecycle.d.ts +10 -1
  40. package/build/manifest.d.ts +69 -0
  41. package/build/manifest.js +229 -0
  42. package/build/manifestSource.d.ts +27 -0
  43. package/build/manifestSource.js +99 -0
  44. package/build/mockShell.d.ts +2 -0
  45. package/build/mockShell.js +13 -0
  46. package/build/query/client.js +9 -1
  47. package/build/query/dependencies.d.ts +22 -0
  48. package/build/query/dependencies.js +73 -0
  49. package/build/query/flows.d.ts +8 -8
  50. package/build/query/index.d.ts +1 -0
  51. package/build/query/index.js +4 -2
  52. package/build/query/layer.d.ts +9 -9
  53. package/build/query/shared.js +10 -0
  54. package/build/query/work.d.ts +4 -4
  55. package/build/rsbuild/index.d.ts +3 -1
  56. package/build/rsbuild/index.js +36 -2
  57. package/build/rsbuild/riseAppManifestPlugin.d.ts +19 -0
  58. package/build/rsbuild/riseAppManifestPlugin.js +79 -0
  59. package/build/shell/installShellBridge.d.ts +2 -0
  60. package/build/shell/installShellBridge.js +3 -1
  61. package/build/shellBridge.d.ts +233 -1
  62. package/build/shellBridge.js +8 -7
  63. package/build/ui/components/app-frame.d.ts +1 -1
  64. package/build/ui/demo.html +365 -360
  65. package/build/ui/shadcn.css +629 -0
  66. package/build/ui/standalone.js +17 -15
  67. package/build/ui/styles.css +1 -1
  68. package/build/ui/tailwind.css +12 -0
  69. package/build/ui/theme.css +412 -0
  70. package/build/ui/tw-animate.css +1 -0
  71. package/build/webpack/index.d.ts +1 -0
  72. package/build/webpack/index.js +7 -0
  73. package/build/webpack/riseAppManifestPlugin.d.ts +61 -0
  74. package/build/webpack/riseAppManifestPlugin.js +103 -0
  75. package/dependencies/package.json +8 -0
  76. package/package.json +17 -4
  77. package/template/AGENTS.md +34 -4
  78. package/template/README.md +85 -2
  79. package/template/package.json +4 -0
  80. package/template/rise-x-app.json +4 -0
  81. package/template/src/App.tsx +7 -17
  82. package/template/src/styles.css +5 -0
  83. package/webpack/package.json +8 -0
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ // Build-time reading of an app's `rise-x-app.json`, shared by both build paths:
3
+ // the webpack plugin (src/webpack) and the Rsbuild preset (src/rsbuild). Node
4
+ // only, and kept out of the root barrel so an app's runtime bundle never pulls
5
+ // in node:fs.
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.MANIFEST_GLOBAL_EXPRESSION = void 0;
41
+ exports.appManifestPath = appManifestPath;
42
+ exports.targetAppEnvironment = targetAppEnvironment;
43
+ exports.readAppManifestSource = readAppManifestSource;
44
+ exports.readResolvedAppManifest = readResolvedAppManifest;
45
+ exports.formatResolvedAppManifest = formatResolvedAppManifest;
46
+ const fs = __importStar(require("node:fs"));
47
+ const path = __importStar(require("node:path"));
48
+ const manifest_1 = require("./manifest");
49
+ // The expression the resolved manifest is substituted into, read at runtime by
50
+ // getAppDependencies(). Kept in sync with src/dependencyRegistry.ts by hand:
51
+ // that module reads the expression rather than publishing it as a string, so
52
+ // there is nothing to import.
53
+ exports.MANIFEST_GLOBAL_EXPRESSION = "globalThis.__RISE_APP_MANIFEST__";
54
+ function appManifestPath(context) {
55
+ return path.join(context, manifest_1.APP_MANIFEST_FILENAME);
56
+ }
57
+ /**
58
+ * The environment to resolve for: an explicit value, else APP_ENV, else the
59
+ * default.
60
+ */
61
+ function targetAppEnvironment(explicit) {
62
+ // `||`, not `??`: an APP_ENV exported as empty means "unset" here, and would
63
+ // otherwise fail the build with `unknown environment ""`.
64
+ return explicit || process.env.APP_ENV || manifest_1.DEFAULT_APP_ENVIRONMENT;
65
+ }
66
+ /**
67
+ * The parsed, unvalidated `rise-x-app.json`, or null when the app declares none.
68
+ * Wrapped, because a file holding the literal `null` is a manifest that has to
69
+ * fail validation, not an absent one.
70
+ *
71
+ * Validating against more than one environment works from the source rather than
72
+ * a resolved copy, so this reads and parses the file once.
73
+ */
74
+ function readAppManifestSource(sourcePath) {
75
+ if (!fs.existsSync(sourcePath))
76
+ return null;
77
+ const raw = fs.readFileSync(sourcePath, "utf8");
78
+ try {
79
+ return { source: JSON.parse(raw) };
80
+ }
81
+ catch (err) {
82
+ throw new Error(`${manifest_1.APP_MANIFEST_FILENAME} is not valid JSON: ${err.message}`);
83
+ }
84
+ }
85
+ /**
86
+ * Null when the app declares no manifest; throws the resolver's error when it
87
+ * declares an invalid one.
88
+ */
89
+ function readResolvedAppManifest(sourcePath, environment) {
90
+ const read = readAppManifestSource(sourcePath);
91
+ if (!read)
92
+ return null;
93
+ return (0, manifest_1.resolveAppManifest)(read.source, environment);
94
+ }
95
+ /** The bytes emitted as `dist/rise-x-app.json` — read by the backend, and by
96
+ * humans reading a deployed zip. */
97
+ function formatResolvedAppManifest(resolved) {
98
+ return `${JSON.stringify(resolved, null, 2)}\n`;
99
+ }
@@ -1,3 +1,4 @@
1
+ import { type ResolvedAppManifest } from "./manifest";
1
2
  import type { DianaShell, ShellAiApi, ShellEnvironment, ShellUser } from "./shellBridge";
2
3
  export interface MockShellFixtures {
3
4
  workRows?: Record<string, unknown[]>;
@@ -16,6 +17,7 @@ export interface CreateMockShellOptions {
16
17
  apiV4?: DianaShell["getApiV4"];
17
18
  fixtures?: MockShellFixtures;
18
19
  ai?: ShellAiApi | null;
20
+ dependencies?: ResolvedAppManifest["dependencies"];
19
21
  }
20
22
  export declare function createMockShell(overrides?: CreateMockShellOptions): DianaShell;
21
23
  export declare function isMockShell(shell: DianaShell): boolean;
@@ -4,6 +4,8 @@ exports.createMockShell = createMockShell;
4
4
  exports.isMockShell = isMockShell;
5
5
  const errors_1 = require("./connectors/errors");
6
6
  const search_1 = require("./connectors/search");
7
+ const dependencyRegistry_1 = require("./dependencyRegistry");
8
+ const manifest_1 = require("./manifest");
7
9
  const shellBridge_1 = require("./shellBridge");
8
10
  // Both helpers return the error rather than throwing it, so every call site
9
11
  // reads as an explicit `throw` instead of a function call that never returns.
@@ -146,6 +148,14 @@ function createFixtureClients(fixtures) {
146
148
  // shell or supply their own instances. Navigate falls back to window.location.
147
149
  function createMockShell(overrides = {}) {
148
150
  const { user = { id: "standalone", name: "Standalone Dev" }, environment = { id: "dev", slug: "dev", name: "Standalone Dev Env" }, ai = null, } = overrides;
151
+ // Cleared when none are passed, so a mock shell built without dependencies
152
+ // never inherits the ones an earlier one registered.
153
+ (0, dependencyRegistry_1.registerAppDependencies)(overrides.dependencies
154
+ ? {
155
+ environment: manifest_1.DEFAULT_APP_ENVIRONMENT,
156
+ dependencies: overrides.dependencies,
157
+ }
158
+ : null);
149
159
  // Both getApi (no arg) and getApiV4 (V4ApiKey arg) need a thrower; we cast the
150
160
  // returned function to whichever signature DianaShell expects at the callsite.
151
161
  const notAvailable = (which) => () => {
@@ -198,6 +208,9 @@ function createMockShell(overrides = {}) {
198
208
  fixtureApiV4 ??
199
209
  notAvailable("getApiV4"),
200
210
  getAi: () => ai,
211
+ // Standalone dev has no cache, outbox or sync engine — null is the honest answer for both.
212
+ getOffline: () => null,
213
+ getCache: () => null,
201
214
  navigate,
202
215
  };
203
216
  // Untyped marker so SDK internals (e.g. the query layer's dev diagnostics)
@@ -46,7 +46,15 @@ function createAppQueryClient(overrides) {
46
46
  staleTime: 30000,
47
47
  gcTime: 5 * 60000,
48
48
  refetchOnWindowFocus: false,
49
- retry: (failureCount, error) => failureCount < 2 && shouldRetryConnectorError(error),
49
+ // Run the first attempt even while the browser is offline — the connectors' read ladder
50
+ // answers from the offline cache, and the 'online' default would pause before the queryFn
51
+ // ever ran. Not 'always': that would also stop reconnect refetches.
52
+ networkMode: "offlineFirst",
53
+ // 'offlineFirst' force-runs only the FIRST attempt; a retry while offline pauses instead,
54
+ // leaving a cache miss pending forever. Fail it now — refetchOnReconnect recovers.
55
+ retry: (failureCount, error) => react_query_1.onlineManager.isOnline() &&
56
+ failureCount < 2 &&
57
+ shouldRetryConnectorError(error),
50
58
  ...overrides?.queries,
51
59
  },
52
60
  mutations: {
@@ -0,0 +1,22 @@
1
+ import type { QueryClient } from "@tanstack/react-query";
2
+ /**
3
+ * Prefetches what every dependency declared in `rise-x-app.json` needs: the flow
4
+ * config and layouts of a flow or asset type, the agent document of an agent (its
5
+ * run stream is SSE, so there is nothing cacheable to warm there). No-ops until
6
+ * the shell reports an environment — the query keys are environment-scoped, and
7
+ * prefetchQuery (unlike the hooks) does not honour `enabled`, so fetching early
8
+ * would fill a null-scoped key — and no-ops when the app declares no manifest,
9
+ * so a `void`-called effect never turns a missing manifest into an unhandled
10
+ * rejection.
11
+ *
12
+ * Pass the client the SDK hooks use, or the warm lands somewhere they never
13
+ * read from:
14
+ *
15
+ * ```tsx
16
+ * const client = useAppQueryClient();
17
+ * useEffect(() => {
18
+ * void prefetchAppDependencies(client);
19
+ * }, [client]);
20
+ * ```
21
+ */
22
+ export declare function prefetchAppDependencies(client: QueryClient): Promise<void>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prefetchAppDependencies = prefetchAppDependencies;
4
+ const bound_1 = require("../dependencies/bound");
5
+ const agents_1 = require("./agents");
6
+ const flows_1 = require("./flows");
7
+ const shared_1 = require("./shared");
8
+ // null is a flow that does not exist (a 404 from getConfig), undefined is a
9
+ // config that was never cached; neither has layouts to warm.
10
+ function layoutIdsOf(config) {
11
+ const ids = new Set();
12
+ for (const step of config?.steps ?? []) {
13
+ for (const task of step.tasks) {
14
+ if (task.layoutId)
15
+ ids.add(task.layoutId);
16
+ }
17
+ }
18
+ return [...ids];
19
+ }
20
+ async function prefetchFlowDependency(client, flowOriginId) {
21
+ const config = flows_1.flowQueries.config(flowOriginId);
22
+ await client.prefetchQuery(config);
23
+ // Read back rather than returning from prefetchQuery (which resolves void):
24
+ // an already-cached config short-circuits the fetch and still gives us the
25
+ // layout ids.
26
+ const layouts = layoutIdsOf(client.getQueryData(config.queryKey));
27
+ await Promise.all(layouts.map((layoutId) => client.prefetchQuery(flows_1.flowQueries.layout(layoutId))));
28
+ }
29
+ /**
30
+ * Prefetches what every dependency declared in `rise-x-app.json` needs: the flow
31
+ * config and layouts of a flow or asset type, the agent document of an agent (its
32
+ * run stream is SSE, so there is nothing cacheable to warm there). No-ops until
33
+ * the shell reports an environment — the query keys are environment-scoped, and
34
+ * prefetchQuery (unlike the hooks) does not honour `enabled`, so fetching early
35
+ * would fill a null-scoped key — and no-ops when the app declares no manifest,
36
+ * so a `void`-called effect never turns a missing manifest into an unhandled
37
+ * rejection.
38
+ *
39
+ * Pass the client the SDK hooks use, or the warm lands somewhere they never
40
+ * read from:
41
+ *
42
+ * ```tsx
43
+ * const client = useAppQueryClient();
44
+ * useEffect(() => {
45
+ * void prefetchAppDependencies(client);
46
+ * }, [client]);
47
+ * ```
48
+ */
49
+ async function prefetchAppDependencies(client) {
50
+ if ((0, shared_1.getLiveEnvId)() == null)
51
+ return;
52
+ const deps = (0, bound_1.tryGetAppDependencies)();
53
+ if (!deps)
54
+ return;
55
+ // Deduped: two aliases may point at the same flow or agent.
56
+ const flowOriginIds = new Set();
57
+ const agentIds = new Set();
58
+ for (const dep of Object.values(deps)) {
59
+ if (dep.kind === "agent")
60
+ agentIds.add(dep.agentId);
61
+ // Nothing to warm: unlike a flow/asset type there is no config document a
62
+ // federated app can read (the integration's own definition carries secret
63
+ // parameters), and invoke's result is per-call, not cacheable app config.
64
+ else if (dep.kind === "integration")
65
+ continue;
66
+ else
67
+ flowOriginIds.add(dep.flowOriginId);
68
+ }
69
+ await Promise.all([
70
+ ...[...flowOriginIds].map((flowOriginId) => prefetchFlowDependency(client, flowOriginId)),
71
+ ...[...agentIds].map((agentId) => client.prefetchQuery(agents_1.agentQueries.detail(agentId))),
72
+ ]);
73
+ }
@@ -23,15 +23,15 @@ export declare function createFlowQueries(connector: FlowsConnector, getEnvId: (
23
23
  } & {
24
24
  queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "detail", string], Flow>;
25
25
  };
26
- config: (flowId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<FlowConfig, Error, FlowConfig, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string]>, "queryFn"> & {
27
- queryFn?: import("@tanstack/react-query").QueryFunction<FlowConfig, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], never> | undefined;
26
+ config: (flowId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<FlowConfig | null, Error, FlowConfig | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string]>, "queryFn"> & {
27
+ queryFn?: import("@tanstack/react-query").QueryFunction<FlowConfig | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], never> | undefined;
28
28
  } & {
29
- queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], FlowConfig>;
29
+ queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], FlowConfig | null>;
30
30
  };
31
- layout: (layoutId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<Layout, Error, Layout, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string]>, "queryFn"> & {
32
- queryFn?: import("@tanstack/react-query").QueryFunction<Layout, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], never> | undefined;
31
+ layout: (layoutId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<Layout | null, Error, Layout | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string]>, "queryFn"> & {
32
+ queryFn?: import("@tanstack/react-query").QueryFunction<Layout | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], never> | undefined;
33
33
  } & {
34
- queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], Layout>;
34
+ queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], Layout | null>;
35
35
  };
36
36
  task: (args: FindTaskQueryArgs) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<FindTaskResult | null, Error, FindTaskResult | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "task", {
37
37
  [x: string]: unknown;
@@ -49,6 +49,6 @@ export type FlowQueries = ReturnType<typeof createFlowQueries>;
49
49
  export declare const flowQueries: FlowQueries;
50
50
  export declare function useFlows(args?: ListFlowsQueryArgs, options?: SdkQueryOptions): UseQueryResult<FlowSummary[], ConnectorError>;
51
51
  export declare function useFlow(flowId: string, options?: SdkQueryOptions): UseQueryResult<Flow, ConnectorError>;
52
- export declare function useFlowConfig(flowId: string, options?: SdkQueryOptions): UseQueryResult<FlowConfig, ConnectorError>;
53
- export declare function useFlowLayout(layoutId: string, options?: SdkQueryOptions): UseQueryResult<Layout, ConnectorError>;
52
+ export declare function useFlowConfig(flowId: string, options?: SdkQueryOptions): UseQueryResult<FlowConfig | null, ConnectorError>;
53
+ export declare function useFlowLayout(layoutId: string, options?: SdkQueryOptions): UseQueryResult<Layout | null, ConnectorError>;
54
54
  export declare function useFlowTask(args: FindTaskQueryArgs, options?: SdkQueryOptions): UseQueryResult<FindTaskResult | null, ConnectorError>;
@@ -4,6 +4,7 @@ export { createAppQueryClient, getFallbackAppClient, shouldRetryConnectorError,
4
4
  export { AppQueryProvider, useAppQueryClient } from "./context";
5
5
  export { getLiveEnvId, invalidateAppSdkQueries, type SdkMutationOptions, type SdkQueryOptions, } from "./shared";
6
6
  export { createQueryLayer, type QueryLayer } from "./layer";
7
+ export { prefetchAppDependencies } from "./dependencies";
7
8
  export { createFlowQueries, flowQueries, useFlow, useFlowConfig, useFlowLayout, useFlows, useFlowTask, type FindTaskQueryArgs, type FlowQueries, type ListFlowsQueryArgs, } from "./flows";
8
9
  export { createWorkQueries, dedupeRows, useDeleteWork, usePatchWorkData, useRelatedWork, useStartWork, useSubmitWork, useWork, useWorkAudit, useWorkData, useWorkRows, useWorkSearch, workQueries, type DeleteWorkVariables, type ListRelatedWorkQueryArgs, type ListWorkRowsQueryArgs, type PatchWorkDataVariables, type SearchWorkQueryArgs, type StartWorkVariables, type SubmitWorkVariables, type WorkQueries, } from "./work";
9
10
  export { assetQueries, createAssetQueries, useAsset, useAssetQuickSearch, useAssetRows, useAssetSearch, useAssetTypes, useCloneAsset, useCreateAsset, useDeleteAsset, useRelatedAssets, useStartEditAsset, type AssetQueries, type CloneAssetVariables, type CreateAssetVariables, type DeleteAssetVariables, type ListAssetRowsQueryArgs, type ListRelatedAssetsQueryArgs, type QuickSearchAssetsQueryArgs, type SearchAssetsQueryArgs, type StartEditAssetVariables, } from "./assets";
@@ -21,8 +21,8 @@
21
21
  // Deliberately NOT re-exported from the package root: apps that don't import
22
22
  // this subpath never load react-query.
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.useAgentChats = exports.useAgentChatMessages = exports.useAgentChat = exports.useAgent = exports.createAgentQueries = exports.agentQueries = exports.useStartEditAsset = exports.useRelatedAssets = exports.useDeleteAsset = exports.useCreateAsset = exports.useCloneAsset = exports.useAssetTypes = exports.useAssetSearch = exports.useAssetRows = exports.useAssetQuickSearch = exports.useAsset = exports.createAssetQueries = exports.assetQueries = exports.workQueries = exports.useWorkSearch = exports.useWorkRows = exports.useWorkData = exports.useWorkAudit = exports.useWork = exports.useSubmitWork = exports.useStartWork = exports.useRelatedWork = exports.usePatchWorkData = exports.useDeleteWork = exports.dedupeRows = exports.createWorkQueries = exports.useFlowTask = exports.useFlows = exports.useFlowLayout = exports.useFlowConfig = exports.useFlow = exports.flowQueries = exports.createFlowQueries = exports.createQueryLayer = exports.invalidateAppSdkQueries = exports.getLiveEnvId = exports.useAppQueryClient = exports.AppQueryProvider = exports.shouldRetryConnectorError = exports.getFallbackAppClient = exports.createAppQueryClient = exports.searchCacheShape = exports.QUERY_KEY_ROOT = exports.queryKeys = exports.normalizeArgs = void 0;
25
- exports.ConnectorError = exports.useUpdateAgent = exports.useRenameAgentChat = exports.useDeleteAgentChat = exports.useDeleteAgent = exports.useCreateAgent = exports.useAgents = void 0;
24
+ exports.useAgentChatMessages = exports.useAgentChat = exports.useAgent = exports.createAgentQueries = exports.agentQueries = exports.useStartEditAsset = exports.useRelatedAssets = exports.useDeleteAsset = exports.useCreateAsset = exports.useCloneAsset = exports.useAssetTypes = exports.useAssetSearch = exports.useAssetRows = exports.useAssetQuickSearch = exports.useAsset = exports.createAssetQueries = exports.assetQueries = exports.workQueries = exports.useWorkSearch = exports.useWorkRows = exports.useWorkData = exports.useWorkAudit = exports.useWork = exports.useSubmitWork = exports.useStartWork = exports.useRelatedWork = exports.usePatchWorkData = exports.useDeleteWork = exports.dedupeRows = exports.createWorkQueries = exports.useFlowTask = exports.useFlows = exports.useFlowLayout = exports.useFlowConfig = exports.useFlow = exports.flowQueries = exports.createFlowQueries = exports.prefetchAppDependencies = exports.createQueryLayer = exports.invalidateAppSdkQueries = exports.getLiveEnvId = exports.useAppQueryClient = exports.AppQueryProvider = exports.shouldRetryConnectorError = exports.getFallbackAppClient = exports.createAppQueryClient = exports.searchCacheShape = exports.QUERY_KEY_ROOT = exports.queryKeys = exports.normalizeArgs = void 0;
25
+ exports.ConnectorError = exports.useUpdateAgent = exports.useRenameAgentChat = exports.useDeleteAgentChat = exports.useDeleteAgent = exports.useCreateAgent = exports.useAgents = exports.useAgentChats = void 0;
26
26
  var keys_1 = require("./keys");
27
27
  Object.defineProperty(exports, "normalizeArgs", { enumerable: true, get: function () { return keys_1.normalizeArgs; } });
28
28
  Object.defineProperty(exports, "queryKeys", { enumerable: true, get: function () { return keys_1.queryKeys; } });
@@ -44,6 +44,8 @@ Object.defineProperty(exports, "getLiveEnvId", { enumerable: true, get: function
44
44
  Object.defineProperty(exports, "invalidateAppSdkQueries", { enumerable: true, get: function () { return shared_1.invalidateAppSdkQueries; } });
45
45
  var layer_1 = require("./layer");
46
46
  Object.defineProperty(exports, "createQueryLayer", { enumerable: true, get: function () { return layer_1.createQueryLayer; } });
47
+ var dependencies_1 = require("./dependencies");
48
+ Object.defineProperty(exports, "prefetchAppDependencies", { enumerable: true, get: function () { return dependencies_1.prefetchAppDependencies; } });
47
49
  var flows_1 = require("./flows");
48
50
  Object.defineProperty(exports, "createFlowQueries", { enumerable: true, get: function () { return flows_1.createFlowQueries; } });
49
51
  Object.defineProperty(exports, "flowQueries", { enumerable: true, get: function () { return flows_1.flowQueries; } });
@@ -18,15 +18,15 @@ export declare function createQueryLayer(deps?: ConnectorDeps): {
18
18
  } & {
19
19
  queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "detail", string], import("../connectors").Flow>;
20
20
  };
21
- config: (flowId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").FlowConfig, Error, import("../connectors").FlowConfig, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string]>, "queryFn"> & {
22
- queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").FlowConfig, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], never> | undefined;
21
+ config: (flowId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").FlowConfig | null, Error, import("../connectors").FlowConfig | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string]>, "queryFn"> & {
22
+ queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").FlowConfig | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], never> | undefined;
23
23
  } & {
24
- queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], import("../connectors").FlowConfig>;
24
+ queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "config", string], import("../connectors").FlowConfig | null>;
25
25
  };
26
- layout: (layoutId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").Layout, Error, import("../connectors").Layout, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string]>, "queryFn"> & {
27
- queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").Layout, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], never> | undefined;
26
+ layout: (layoutId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").Layout | null, Error, import("../connectors").Layout | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string]>, "queryFn"> & {
27
+ queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").Layout | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], never> | undefined;
28
28
  } & {
29
- queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], import("../connectors").Layout>;
29
+ queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "flows", "layout", string], import("../connectors").Layout | null>;
30
30
  };
31
31
  task: (args: import("./flows").FindTaskQueryArgs) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors/flows").FindTaskResult | null, Error, import("../connectors/flows").FindTaskResult | null, readonly ["rise-apps-sdk", QueryEnvId, "flows", "task", {
32
32
  [x: string]: unknown;
@@ -41,10 +41,10 @@ export declare function createQueryLayer(deps?: ConnectorDeps): {
41
41
  };
42
42
  };
43
43
  workQueries: {
44
- detail: (workId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").WorkDetail, Error, import("../connectors").WorkDetail, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string]>, "queryFn"> & {
45
- queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").WorkDetail, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], never> | undefined;
44
+ detail: (workId: string) => import("@tanstack/query-core").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../connectors").WorkDetail | null, Error, import("../connectors").WorkDetail | null, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string]>, "queryFn"> & {
45
+ queryFn?: import("@tanstack/query-core").QueryFunction<import("../connectors").WorkDetail | null, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], never> | undefined;
46
46
  } & {
47
- queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], import("../connectors").WorkDetail>;
47
+ queryKey: import("@tanstack/query-core").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], import("../connectors").WorkDetail | null>;
48
48
  };
49
49
  data: (workId: string, opts?: {
50
50
  path?: string;
@@ -82,12 +82,19 @@ function useEnvSubscription() {
82
82
  const [, setEnv] = (0, react_1.useState)(() => shell?.getEnvironment() ?? null);
83
83
  (0, react_1.useEffect)(() => shell?.subscribeEnvironment(setEnv), [shell]);
84
84
  }
85
+ // A per-call `retry` count (or `true`) would replace the client default and with it the offline
86
+ // guard, resurrecting the paused-forever pending on an offline cache miss (see client.ts).
87
+ // Compose instead: honour the cap, keep the guard. `false`/`0` already error immediately.
88
+ const guardRetry = (retry) => (failureCount) => react_query_1.onlineManager.isOnline() && (retry === true || failureCount < retry);
85
89
  function useSdkQuery(built, options) {
86
90
  useEnvSubscription();
87
91
  const client = (0, context_1.useAppQueryClient)();
88
92
  const merged = {
89
93
  ...built,
90
94
  ...options,
95
+ ...(typeof options?.retry === "number" || options?.retry === true
96
+ ? { retry: guardRetry(options.retry) }
97
+ : {}),
91
98
  enabled: built.enabled === true && (options?.enabled ?? true),
92
99
  };
93
100
  return (0, react_query_1.useQuery)(merged, client);
@@ -98,6 +105,9 @@ function useSdkInfiniteQuery(built, options) {
98
105
  const merged = {
99
106
  ...built,
100
107
  ...options,
108
+ ...(typeof options?.retry === "number" || options?.retry === true
109
+ ? { retry: guardRetry(options.retry) }
110
+ : {}),
101
111
  enabled: built.enabled === true && (options?.enabled ?? true),
102
112
  };
103
113
  return (0, react_query_1.useInfiniteQuery)(merged, client);
@@ -13,10 +13,10 @@ export declare function dedupeRows<T extends {
13
13
  items: T[];
14
14
  }> | undefined): T[];
15
15
  export declare function createWorkQueries(connector: WorkConnector, getEnvId: () => QueryEnvId): {
16
- detail: (workId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<WorkDetail, Error, WorkDetail, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string]>, "queryFn"> & {
17
- queryFn?: import("@tanstack/react-query").QueryFunction<WorkDetail, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], never> | undefined;
16
+ detail: (workId: string) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<WorkDetail | null, Error, WorkDetail | null, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string]>, "queryFn"> & {
17
+ queryFn?: import("@tanstack/react-query").QueryFunction<WorkDetail | null, readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], never> | undefined;
18
18
  } & {
19
- queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], WorkDetail>;
19
+ queryKey: import("@tanstack/react-query").DataTag<readonly ["rise-apps-sdk", QueryEnvId, "work", "detail", string], WorkDetail | null>;
20
20
  };
21
21
  data: (workId: string, opts?: {
22
22
  path?: string;
@@ -66,7 +66,7 @@ export declare function createWorkQueries(connector: WorkConnector, getEnvId: ()
66
66
  };
67
67
  export type WorkQueries = ReturnType<typeof createWorkQueries>;
68
68
  export declare const workQueries: WorkQueries;
69
- export declare function useWork(workId: string, options?: SdkQueryOptions): UseQueryResult<WorkDetail, ConnectorError>;
69
+ export declare function useWork(workId: string, options?: SdkQueryOptions): UseQueryResult<WorkDetail | null, ConnectorError>;
70
70
  export declare function useWorkData(workId: string, opts?: {
71
71
  path?: string;
72
72
  }, options?: SdkQueryOptions): UseQueryResult<unknown, ConnectorError>;
@@ -1,4 +1,5 @@
1
1
  import type { RsbuildConfig } from '@rsbuild/core';
2
+ export { pluginRiseAppManifest, type RiseAppManifestRsbuildPluginOptions, } from './riseAppManifestPlugin';
2
3
  export interface AppPackageJson {
3
4
  name: string;
4
5
  version?: string;
@@ -24,7 +25,8 @@ export interface DefineAppConfigOptions {
24
25
  exposes?: Record<string, string>;
25
26
  /**
26
27
  * Extra `source.define` entries. Values are raw code, so strings arrive
27
- * quoted: `{ __MODE__: JSON.stringify('sample') }`. `__APP_VERSION__` throws.
28
+ * quoted: `{ __MODE__: JSON.stringify('sample') }`. `__APP_VERSION__` and
29
+ * `__APP_SCOPE__` throw — both are derived here.
28
30
  */
29
31
  define?: Record<string, string>;
30
32
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pluginRiseAppManifest = void 0;
3
4
  exports.deriveAppScope = deriveAppScope;
4
5
  exports.defineAppConfig = defineAppConfig;
5
6
  const node_module_1 = require("node:module");
@@ -7,6 +8,11 @@ const node_path_1 = require("node:path");
7
8
  const plugin_react_1 = require("@rsbuild/plugin-react");
8
9
  const plugin_type_check_1 = require("@rsbuild/plugin-type-check");
9
10
  const lifecycle_1 = require("../lifecycle");
11
+ const riseAppManifestPlugin_1 = require("./riseAppManifestPlugin");
12
+ // Re-exported so an app with a hand-rolled Rsbuild config can wire the manifest
13
+ // itself, the way '@rise-x/apps-sdk/webpack' exposes its plugin.
14
+ var riseAppManifestPlugin_2 = require("./riseAppManifestPlugin");
15
+ Object.defineProperty(exports, "pluginRiseAppManifest", { enumerable: true, get: function () { return riseAppManifestPlugin_2.pluginRiseAppManifest; } });
10
16
  // The shell validates an app's scope against this, and `uniqueName` (the
11
17
  // chunk-loading global) is the same string — so an invalid scope fails at
12
18
  // runtime in ways that are hard to trace. Fail at config time instead.
@@ -26,7 +32,7 @@ const SCOPE_PATTERN = /^[a-z][a-z0-9_]*$/;
26
32
  // does not satisfy — it logs one warning per shared entry on every app load, and
27
33
  // it states a constraint the apps do not actually have. Both hosts DERIVE the
28
34
  // version they provide from the resolved package precisely so it cannot rot
29
- // (see ClientApp/webpack.config.js).
35
+ // (see ClientApp/rsbuild.config.ts).
30
36
  //
31
37
  // The range matches this package's own `react` peer range, and
32
38
  // apps/medication-identifier already ships it in production. Be precise about
@@ -76,6 +82,11 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
76
82
  'from pkg.version so it always matches the deployed manifest. Change the version ' +
77
83
  'in package.json instead.');
78
84
  }
85
+ if (define && '__APP_SCOPE__' in define) {
86
+ throw new Error('defineAppConfig: __APP_SCOPE__ cannot be set through `define` — it is derived ' +
87
+ 'from pkg.name (or APP_SCOPE) so it always matches the registered MF scope. Set ' +
88
+ 'APP_SCOPE instead.');
89
+ }
79
90
  const base = {
80
91
  // pluginTypeCheck is NOT optional polish. The webpack configs this preset
81
92
  // replaces used ts-loader, which type-checked on every build, and that pass
@@ -85,15 +96,35 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
85
96
  // packages/ui and ClientApp. Rsbuild transpiles with SWC, which strips
86
97
  // types without checking them, so without this `pnpm build` would happily
87
98
  // produce a deploy artifact from code that does not compile.
88
- plugins: [(0, plugin_react_1.pluginReact)(), (0, plugin_type_check_1.pluginTypeCheck)()],
99
+ //
100
+ // pluginRiseAppManifest resolves the app's rise-x-app.json for ONE
101
+ // environment, emits it into the build output and injects it as a
102
+ // compile-time constant. In BOTH modes: standalone dev of an app that reads
103
+ // useAppDependencies() then works without re-declaring the ids by hand.
104
+ plugins: [(0, plugin_react_1.pluginReact)(), (0, plugin_type_check_1.pluginTypeCheck)(), (0, riseAppManifestPlugin_1.pluginRiseAppManifest)()],
89
105
  source: {
90
106
  entry: { index: './src/index.tsx' },
91
107
  define: {
92
108
  ...define,
93
109
  __APP_VERSION__: JSON.stringify(pkg.version ?? '0.0.0'),
110
+ // The app's own MF scope, for connectors that label requests with it
111
+ // (e.g. the vector-stores connector's X-Rise-App header). The same
112
+ // spelling is also the scaffolder's text-replacement token (cli/init.ts)
113
+ // — a template file that writes it gets substituted at `init` time and
114
+ // never reaches this define.
115
+ __APP_SCOPE__: JSON.stringify(scope),
94
116
  },
95
117
  },
96
118
  html: { template: './public/index.html' },
119
+ output: {
120
+ // The app's CSS rides inside its JS: a host does no CSS chunk loading for remotes.
121
+ injectStyles: true,
122
+ },
123
+ tools: {
124
+ // Apps compile their own Tailwind utilities; the host ships only the design system's.
125
+ // `require`, not `import`: moduleResolution 'node' cannot follow @tailwindcss/postcss's `exports`.
126
+ postcss: (_, { addPlugins }) => addPlugins(require('@tailwindcss/postcss')()),
127
+ },
97
128
  server: {
98
129
  port,
99
130
  historyApiFallback: true,
@@ -110,6 +141,7 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
110
141
  return {
111
142
  ...base,
112
143
  output: {
144
+ ...base.output,
113
145
  distPath: { root: 'dist-local' },
114
146
  assetPrefix: '/',
115
147
  },
@@ -136,6 +168,7 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
136
168
  return {
137
169
  ...base,
138
170
  output: {
171
+ ...base.output,
139
172
  // Flat dist: remoteEntry.js plus its sibling chunks at the archive root.
140
173
  // tools/apps-dev-server probes `dist/remoteEntry.js`, and the deploy zips
141
174
  // the CONTENTS of dist/ with remoteEntry.js at the top level.
@@ -172,6 +205,7 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
172
205
  headers: { 'Access-Control-Allow-Origin': '*' },
173
206
  },
174
207
  tools: {
208
+ ...base.tools,
175
209
  rspack: (config, { rspack, appendPlugins, isProd }) => {
176
210
  // Rsbuild defaults production source maps OFF; the webpack configs this
177
211
  // replaces shipped them, and without them a deployed app is unreadable
@@ -0,0 +1,19 @@
1
+ import type { RsbuildPlugin } from "@rsbuild/core";
2
+ export declare const RISE_APP_MANIFEST_PLUGIN_NAME = "rise-x:app-manifest";
3
+ export interface RiseAppManifestRsbuildPluginOptions {
4
+ /** Directory holding rise-x-app.json. Defaults to the Rsbuild root. */
5
+ context?: string;
6
+ /** Target environment. Defaults to APP_ENV, then DEFAULT_APP_ENVIRONMENT. */
7
+ environment?: string;
8
+ }
9
+ /**
10
+ * The Rsbuild half of the app-dependency manifest, and the counterpart of
11
+ * RiseAppManifestPlugin from '@rise-x/apps-sdk/webpack'. Resolves the app's
12
+ * `rise-x-app.json` for one environment, emits the result into the build output
13
+ * (so the backend can read the app's dependencies out of the deployed zip), and
14
+ * injects it as a compile-time constant (so `getAppDependencies()` can read it
15
+ * at runtime). No-ops when the app declares no manifest.
16
+ *
17
+ * `defineAppConfig` wires this in, so an app using the preset needs nothing.
18
+ */
19
+ export declare function pluginRiseAppManifest(options?: RiseAppManifestRsbuildPluginOptions): RsbuildPlugin;