@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.
Files changed (185) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +553 -0
  3. package/build/_internal.d.ts +2 -0
  4. package/build/_internal.js +23 -0
  5. package/build/accessors.d.ts +8 -0
  6. package/build/accessors.js +40 -0
  7. package/build/cli/index.d.ts +13 -0
  8. package/build/cli/index.js +54 -0
  9. package/build/cli/init.d.ts +6 -0
  10. package/build/cli/init.js +179 -0
  11. package/build/cli/templating.d.ts +2 -0
  12. package/build/cli/templating.js +84 -0
  13. package/build/connectors/agents.d.ts +85 -0
  14. package/build/connectors/agents.js +404 -0
  15. package/build/connectors/assets.d.ts +76 -0
  16. package/build/connectors/assets.js +204 -0
  17. package/build/connectors/deps.d.ts +4 -0
  18. package/build/connectors/deps.js +2 -0
  19. package/build/connectors/errors.d.ts +11 -0
  20. package/build/connectors/errors.js +67 -0
  21. package/build/connectors/flows.d.ts +37 -0
  22. package/build/connectors/flows.js +191 -0
  23. package/build/connectors/index.d.ts +8 -0
  24. package/build/connectors/index.js +50 -0
  25. package/build/connectors/sse.d.ts +12 -0
  26. package/build/connectors/sse.js +157 -0
  27. package/build/connectors/types.d.ts +285 -0
  28. package/build/connectors/types.js +419 -0
  29. package/build/connectors/work.d.ts +84 -0
  30. package/build/connectors/work.js +224 -0
  31. package/build/hooks.d.ts +4 -0
  32. package/build/hooks.js +28 -0
  33. package/build/index.d.ts +6 -0
  34. package/build/index.js +34 -0
  35. package/build/lifecycle.d.ts +23 -0
  36. package/build/lifecycle.js +6 -0
  37. package/build/mockShell.d.ts +10 -0
  38. package/build/mockShell.js +55 -0
  39. package/build/query/agents.d.ts +80 -0
  40. package/build/query/agents.js +143 -0
  41. package/build/query/assets.d.ts +73 -0
  42. package/build/query/assets.js +152 -0
  43. package/build/query/client.d.ts +5 -0
  44. package/build/query/client.js +68 -0
  45. package/build/query/context.d.ts +2 -0
  46. package/build/query/context.js +34 -0
  47. package/build/query/flows.d.ts +54 -0
  48. package/build/query/flows.js +81 -0
  49. package/build/query/index.d.ts +10 -0
  50. package/build/query/index.js +85 -0
  51. package/build/query/keys.d.ts +51 -0
  52. package/build/query/keys.js +79 -0
  53. package/build/query/layer.d.ts +175 -0
  54. package/build/query/layer.js +35 -0
  55. package/build/query/shared.d.ts +43 -0
  56. package/build/query/shared.js +116 -0
  57. package/build/query/work.d.ts +75 -0
  58. package/build/query/work.js +172 -0
  59. package/build/shell/index.d.ts +1 -0
  60. package/build/shell/index.js +6 -0
  61. package/build/shell/installShellBridge.d.ts +11 -0
  62. package/build/shell/installShellBridge.js +104 -0
  63. package/build/shellBridge.d.ts +36 -0
  64. package/build/shellBridge.js +10 -0
  65. package/build/topBar.d.ts +25 -0
  66. package/build/topBar.js +17 -0
  67. package/build/ui/components/ai.d.ts +49 -0
  68. package/build/ui/components/alert-dialog.d.ts +27 -0
  69. package/build/ui/components/alert.d.ts +14 -0
  70. package/build/ui/components/avatar.d.ts +17 -0
  71. package/build/ui/components/badge.d.ts +19 -0
  72. package/build/ui/components/button.d.ts +13 -0
  73. package/build/ui/components/calendar.d.ts +21 -0
  74. package/build/ui/components/card.d.ts +16 -0
  75. package/build/ui/components/chart.d.ts +124 -0
  76. package/build/ui/components/checkbox.d.ts +4 -0
  77. package/build/ui/components/data-table.d.ts +70 -0
  78. package/build/ui/components/dialog.d.ts +17 -0
  79. package/build/ui/components/dropdown-menu.d.ts +29 -0
  80. package/build/ui/components/empty-state.d.ts +7 -0
  81. package/build/ui/components/file-upload.d.ts +17 -0
  82. package/build/ui/components/input.d.ts +8 -0
  83. package/build/ui/components/label.d.ts +4 -0
  84. package/build/ui/components/list.d.ts +24 -0
  85. package/build/ui/components/map.d.ts +26 -0
  86. package/build/ui/components/message.d.ts +24 -0
  87. package/build/ui/components/nav.d.ts +12 -0
  88. package/build/ui/components/page-header.d.ts +27 -0
  89. package/build/ui/components/popover.d.ts +10 -0
  90. package/build/ui/components/progress.d.ts +4 -0
  91. package/build/ui/components/radio.d.ts +6 -0
  92. package/build/ui/components/resizable.d.ts +7 -0
  93. package/build/ui/components/scroll-area.d.ts +5 -0
  94. package/build/ui/components/segmented.d.ts +6 -0
  95. package/build/ui/components/select.d.ts +15 -0
  96. package/build/ui/components/separator.d.ts +4 -0
  97. package/build/ui/components/sheet.d.ts +14 -0
  98. package/build/ui/components/skeleton.d.ts +3 -0
  99. package/build/ui/components/slider.d.ts +15 -0
  100. package/build/ui/components/snackbar.d.ts +3 -0
  101. package/build/ui/components/sonner.d.ts +4 -0
  102. package/build/ui/components/spinner.d.ts +5 -0
  103. package/build/ui/components/statistic.d.ts +19 -0
  104. package/build/ui/components/stepper.d.ts +12 -0
  105. package/build/ui/components/switch.d.ts +6 -0
  106. package/build/ui/components/table.d.ts +24 -0
  107. package/build/ui/components/textarea.d.ts +3 -0
  108. package/build/ui/components/timeline.d.ts +15 -0
  109. package/build/ui/components/toggle-group.d.ts +10 -0
  110. package/build/ui/components/toggle.d.ts +9 -0
  111. package/build/ui/components/tooltip.d.ts +7 -0
  112. package/build/ui/index.d.ts +46 -0
  113. package/build/ui/index.js +8 -0
  114. package/build/ui/lib/utils.d.ts +2 -0
  115. package/build/ui/reference/README.md +11 -0
  116. package/build/ui/reference/components/ai.tsx +291 -0
  117. package/build/ui/reference/components/alert-dialog.tsx +208 -0
  118. package/build/ui/reference/components/alert.tsx +112 -0
  119. package/build/ui/reference/components/avatar.tsx +158 -0
  120. package/build/ui/reference/components/badge.tsx +160 -0
  121. package/build/ui/reference/components/button.tsx +100 -0
  122. package/build/ui/reference/components/calendar.tsx +119 -0
  123. package/build/ui/reference/components/card.tsx +144 -0
  124. package/build/ui/reference/components/chart.tsx +1394 -0
  125. package/build/ui/reference/components/checkbox.tsx +44 -0
  126. package/build/ui/reference/components/data-table.tsx +480 -0
  127. package/build/ui/reference/components/dialog.tsx +172 -0
  128. package/build/ui/reference/components/dropdown-menu.tsx +245 -0
  129. package/build/ui/reference/components/empty-state.tsx +63 -0
  130. package/build/ui/reference/components/file-upload.tsx +116 -0
  131. package/build/ui/reference/components/input.tsx +114 -0
  132. package/build/ui/reference/components/label.tsx +19 -0
  133. package/build/ui/reference/components/list.tsx +191 -0
  134. package/build/ui/reference/components/map.css +251 -0
  135. package/build/ui/reference/components/map.tsx +294 -0
  136. package/build/ui/reference/components/message.tsx +171 -0
  137. package/build/ui/reference/components/nav.tsx +113 -0
  138. package/build/ui/reference/components/page-header.tsx +213 -0
  139. package/build/ui/reference/components/popover.tsx +76 -0
  140. package/build/ui/reference/components/progress.tsx +31 -0
  141. package/build/ui/reference/components/radio.tsx +65 -0
  142. package/build/ui/reference/components/resizable.tsx +40 -0
  143. package/build/ui/reference/components/scroll-area.tsx +55 -0
  144. package/build/ui/reference/components/segmented.tsx +45 -0
  145. package/build/ui/reference/components/select.tsx +185 -0
  146. package/build/ui/reference/components/separator.tsx +26 -0
  147. package/build/ui/reference/components/sheet.tsx +173 -0
  148. package/build/ui/reference/components/skeleton.tsx +15 -0
  149. package/build/ui/reference/components/slider.tsx +161 -0
  150. package/build/ui/reference/components/snackbar.tsx +27 -0
  151. package/build/ui/reference/components/sonner.tsx +43 -0
  152. package/build/ui/reference/components/spinner.tsx +27 -0
  153. package/build/ui/reference/components/statistic.tsx +122 -0
  154. package/build/ui/reference/components/stepper.tsx +138 -0
  155. package/build/ui/reference/components/switch.tsx +47 -0
  156. package/build/ui/reference/components/table.tsx +233 -0
  157. package/build/ui/reference/components/textarea.tsx +28 -0
  158. package/build/ui/reference/components/timeline.tsx +94 -0
  159. package/build/ui/reference/components/toggle-group.tsx +86 -0
  160. package/build/ui/reference/components/toggle.tsx +46 -0
  161. package/build/ui/reference/components/tooltip.tsx +53 -0
  162. package/build/ui/reference/index.ts +49 -0
  163. package/build/ui/reference/lib/utils.ts +34 -0
  164. package/build/ui/standalone-stub.js +5 -0
  165. package/build/ui/standalone.js +135 -0
  166. package/build/ui/styles.css +3 -0
  167. package/connectors/package.json +8 -0
  168. package/package.json +114 -0
  169. package/query/package.json +8 -0
  170. package/shell/package.json +8 -0
  171. package/template/AGENTS.md +70 -0
  172. package/template/CLAUDE.md +4 -0
  173. package/template/README.md +102 -0
  174. package/template/_gitignore +6 -0
  175. package/template/commitlint.config.js +12 -0
  176. package/template/package.json +31 -0
  177. package/template/public/index.html +13 -0
  178. package/template/src/App.tsx +171 -0
  179. package/template/src/bootstrap.tsx +13 -0
  180. package/template/src/index.tsx +1 -0
  181. package/template/src/lifecycle.ts +20 -0
  182. package/template/tsconfig.json +31 -0
  183. package/template/webpack.config.js +112 -0
  184. package/template/webpack.local.config.js +68 -0
  185. package/ui/package.json +8 -0
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const node_util_1 = require("node:util");
5
+ const init_1 = require("./init");
6
+ function printUsage() {
7
+ console.error(`Usage: apps-sdk init <name> [options]
8
+
9
+ Creates a new Rise-X federated app in the current directory.
10
+
11
+ Options:
12
+ --pm=<npm|yarn|pnpm> Package manager (default: auto-detect from cwd lockfiles)
13
+ --port=<n> Standalone dev-server port (default: 5101)
14
+ --skip-install Skip <pm> install after scaffolding
15
+ --json Emit { path, slug, scope, pkgName, port, pm } on stdout
16
+ --help, -h Show this help
17
+ `);
18
+ }
19
+ function parseCli() {
20
+ return (0, node_util_1.parseArgs)({
21
+ args: process.argv.slice(2),
22
+ options: {
23
+ pm: { type: "string" },
24
+ port: { type: "string" },
25
+ "skip-install": { type: "boolean" },
26
+ json: { type: "boolean" },
27
+ help: { type: "boolean", short: "h" },
28
+ },
29
+ allowPositionals: true,
30
+ });
31
+ }
32
+ async function main() {
33
+ const parsed = parseCli();
34
+ if (parsed.values.help) {
35
+ printUsage();
36
+ return;
37
+ }
38
+ const [command, ...positional] = parsed.positionals;
39
+ if (!command) {
40
+ printUsage();
41
+ process.exit(1);
42
+ }
43
+ if (command !== "init") {
44
+ console.error(`Unknown command: ${command}`);
45
+ printUsage();
46
+ process.exit(1);
47
+ }
48
+ await (0, init_1.init)({ positional, flags: parsed.values });
49
+ }
50
+ main().catch((err) => {
51
+ const message = err instanceof Error ? err.message : String(err);
52
+ console.error(`apps-sdk: ${message}`);
53
+ process.exit(1);
54
+ });
@@ -0,0 +1,6 @@
1
+ import type { CliFlags } from "./index";
2
+ export interface InitArgs {
3
+ positional: string[];
4
+ flags: CliFlags;
5
+ }
6
+ export declare function init(args: InitArgs): Promise<void>;
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.init = init;
37
+ const fs = __importStar(require("node:fs"));
38
+ const path = __importStar(require("node:path"));
39
+ const node_child_process_1 = require("node:child_process");
40
+ const templating_1 = require("./templating");
41
+ const PACKAGE_MANAGERS = ["npm", "yarn", "pnpm"];
42
+ const VALID_SLUG = /^[a-z][a-z0-9-]*$/;
43
+ const MAX_SLUG_LENGTH = 40;
44
+ const DEFAULT_PORT = 5101;
45
+ function isPackageManager(v) {
46
+ return PACKAGE_MANAGERS.includes(v);
47
+ }
48
+ function detectPackageManager(cwd) {
49
+ if (fs.existsSync(path.join(cwd, "yarn.lock")))
50
+ return "yarn";
51
+ if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml")))
52
+ return "pnpm";
53
+ return "npm";
54
+ }
55
+ function findPackageRoot() {
56
+ // In the built output __dirname is <pkg>/build/cli; from source it is <pkg>/src/cli.
57
+ return path.resolve(__dirname, "..", "..");
58
+ }
59
+ function findTemplateRoot() {
60
+ return path.join(findPackageRoot(), "template");
61
+ }
62
+ // The scaffolded app depends on the SDK version that scaffolded it, so the
63
+ // template carries a token rather than a pin that has to be hand-bumped.
64
+ function readSdkVersion() {
65
+ const pkgPath = path.join(findPackageRoot(), "package.json");
66
+ const { version } = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
67
+ if (!version)
68
+ throw new Error(`No version field in ${pkgPath}`);
69
+ return version;
70
+ }
71
+ // `shell: true` is only needed on Windows (to resolve .cmd shims for npm/yarn/pnpm).
72
+ // All args are static — no user input reaches the shell.
73
+ function run(cmd, args, cwd, stdio) {
74
+ const result = (0, node_child_process_1.spawnSync)(cmd, args, {
75
+ cwd,
76
+ stdio,
77
+ shell: process.platform === "win32",
78
+ });
79
+ if (result.error)
80
+ throw result.error;
81
+ if (result.status !== 0) {
82
+ throw new Error(`${cmd} ${args.join(" ")} failed with exit code ${result.status}`);
83
+ }
84
+ }
85
+ async function init(args) {
86
+ const name = args.positional[0];
87
+ if (!name) {
88
+ throw new Error("Missing <name> argument. Usage: apps-sdk init <name>");
89
+ }
90
+ if (!VALID_SLUG.test(name)) {
91
+ throw new Error(`Invalid name "${name}". Must be kebab-case (lowercase, start with a letter).`);
92
+ }
93
+ if (name.length > MAX_SLUG_LENGTH) {
94
+ throw new Error(`Invalid name: max ${MAX_SLUG_LENGTH} characters (got ${name.length}).`);
95
+ }
96
+ const cwd = process.cwd();
97
+ const targetDir = path.join(cwd, name);
98
+ const portRaw = args.flags.port;
99
+ const port = portRaw !== undefined ? parseInt(portRaw, 10) : DEFAULT_PORT;
100
+ if (Number.isNaN(port) || port <= 0 || port > 65535) {
101
+ throw new Error(`Invalid --port value: ${String(portRaw)}`);
102
+ }
103
+ const pmFlag = args.flags.pm;
104
+ let pm;
105
+ if (pmFlag === undefined) {
106
+ pm = detectPackageManager(cwd);
107
+ }
108
+ else if (isPackageManager(pmFlag)) {
109
+ pm = pmFlag;
110
+ }
111
+ else {
112
+ throw new Error(`Invalid --pm value: ${pmFlag} (expected ${PACKAGE_MANAGERS.join(", ")})`);
113
+ }
114
+ const skipInstall = args.flags["skip-install"] === true;
115
+ const jsonOutput = args.flags.json === true;
116
+ const slug = name;
117
+ const pkgName = `@rise-x-apps/${slug}`;
118
+ const scope = `app_${slug.replace(/-/g, "_")}`;
119
+ const tokens = {
120
+ __APP_SLUG__: slug,
121
+ __APP_SCOPE__: scope,
122
+ __APP_PKG_NAME__: pkgName,
123
+ __APP_PORT__: String(port),
124
+ __SDK_VERSION__: `^${readSdkVersion()}`,
125
+ };
126
+ const templateRoot = findTemplateRoot();
127
+ if (!fs.existsSync(templateRoot)) {
128
+ throw new Error(`Template directory not found at ${templateRoot}`);
129
+ }
130
+ // mkdir without `recursive` so we get a clear EEXIST if the target is already there —
131
+ // avoids the TOCTOU window that a pre-check + recursive create would leave open.
132
+ try {
133
+ fs.mkdirSync(targetDir);
134
+ }
135
+ catch (err) {
136
+ const code = err.code;
137
+ if (code === "EEXIST") {
138
+ throw new Error(`Directory already exists: ${targetDir}`);
139
+ }
140
+ throw err;
141
+ }
142
+ (0, templating_1.copyTemplate)(templateRoot, targetDir, tokens);
143
+ // npm strips files named `.gitignore` (under gitignore-fallback packing) from the
144
+ // published tarball, so the template ships them under `_`-prefixed names and we
145
+ // rename them back here.
146
+ for (const [staged, final] of [["_gitignore", ".gitignore"]]) {
147
+ const stagedPath = path.join(targetDir, staged);
148
+ if (fs.existsSync(stagedPath)) {
149
+ fs.renameSync(stagedPath, path.join(targetDir, final));
150
+ }
151
+ }
152
+ const stdio = jsonOutput ? "ignore" : "inherit";
153
+ if (!skipInstall) {
154
+ if (!jsonOutput)
155
+ console.error(`Installing with ${pm}…`);
156
+ run(pm, ["install"], targetDir, stdio);
157
+ }
158
+ if (jsonOutput) {
159
+ process.stdout.write(JSON.stringify({
160
+ path: targetDir,
161
+ slug,
162
+ scope,
163
+ pkgName,
164
+ port,
165
+ pm,
166
+ installed: !skipInstall,
167
+ }) + "\n");
168
+ return;
169
+ }
170
+ console.log("");
171
+ console.log(` Created ${pkgName} in ${targetDir}`);
172
+ console.log("");
173
+ console.log(" Next steps:");
174
+ console.log(` cd ${name}`);
175
+ if (skipInstall)
176
+ console.log(` ${pm} install`);
177
+ console.log(` ${pm} start # run standalone on port ${port}`);
178
+ console.log("");
179
+ }
@@ -0,0 +1,2 @@
1
+ export type TokenMap = Record<string, string>;
2
+ export declare function copyTemplate(src: string, dst: string, tokens: TokenMap): void;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.copyTemplate = copyTemplate;
37
+ const fs = __importStar(require("node:fs"));
38
+ const path = __importStar(require("node:path"));
39
+ // Binary file extensions — copied verbatim, never touched by token replace.
40
+ const BINARY_EXTS = new Set([
41
+ '.png',
42
+ '.jpg',
43
+ '.jpeg',
44
+ '.gif',
45
+ '.webp',
46
+ '.ico',
47
+ '.woff',
48
+ '.woff2',
49
+ '.ttf',
50
+ '.otf',
51
+ '.eot',
52
+ '.pdf',
53
+ '.zip',
54
+ '.tar',
55
+ '.gz',
56
+ ]);
57
+ function replaceTokens(content, tokens) {
58
+ const keys = Object.keys(tokens);
59
+ if (keys.length === 0)
60
+ return content;
61
+ const pattern = new RegExp(keys.map((k) => k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|'), 'g');
62
+ return content.replace(pattern, (m) => tokens[m] ?? m);
63
+ }
64
+ function copyTemplate(src, dst, tokens) {
65
+ const entries = fs.readdirSync(src, { withFileTypes: true });
66
+ for (const entry of entries) {
67
+ const srcPath = path.join(src, entry.name);
68
+ const dstPath = path.join(dst, entry.name);
69
+ if (entry.isDirectory()) {
70
+ fs.mkdirSync(dstPath, { recursive: true });
71
+ copyTemplate(srcPath, dstPath, tokens);
72
+ continue;
73
+ }
74
+ if (!entry.isFile())
75
+ continue;
76
+ const ext = path.extname(entry.name).toLowerCase();
77
+ if (BINARY_EXTS.has(ext)) {
78
+ fs.copyFileSync(srcPath, dstPath);
79
+ continue;
80
+ }
81
+ const contents = fs.readFileSync(srcPath, 'utf8');
82
+ fs.writeFileSync(dstPath, replaceTokens(contents, tokens));
83
+ }
84
+ }
@@ -0,0 +1,85 @@
1
+ import type { ConnectorDeps } from "./deps";
2
+ import { type AgentChat as AgentChatRecord, type AgentChatMessagePage, type AgentChatPage, type AgentCreateInput, type AgentPage, type AgentPatch, type AgentRunEndReason, type AgentRunEvent, type RiseAgent } from "./types";
3
+ export interface ListAgentsArgs {
4
+ search?: string;
5
+ page?: number;
6
+ pageSize?: number;
7
+ signal?: AbortSignal;
8
+ }
9
+ export interface RunAgentArgs {
10
+ agentId: string;
11
+ message: string;
12
+ chatId?: string;
13
+ useHistory?: boolean;
14
+ sessionId?: string;
15
+ context?: Record<string, unknown>;
16
+ signal?: AbortSignal;
17
+ }
18
+ export interface SendChatArgs {
19
+ context?: Record<string, unknown>;
20
+ signal?: AbortSignal;
21
+ }
22
+ export interface AgentChatSession {
23
+ readonly agentId: string;
24
+ readonly chatId: string | undefined;
25
+ send(message: string, opts?: SendChatArgs): AsyncIterable<AgentRunEvent>;
26
+ reset(): void;
27
+ }
28
+ export interface ListChatsArgs {
29
+ agentId?: string;
30
+ page?: number;
31
+ pageSize?: number;
32
+ signal?: AbortSignal;
33
+ }
34
+ export interface GetChatMessagesArgs {
35
+ fromSeq?: number;
36
+ pageSize?: number;
37
+ signal?: AbortSignal;
38
+ }
39
+ export interface AgentsConnector {
40
+ list(args?: ListAgentsArgs): Promise<AgentPage>;
41
+ get(id: string, opts?: {
42
+ signal?: AbortSignal;
43
+ }): Promise<RiseAgent>;
44
+ create(input: AgentCreateInput, opts?: {
45
+ signal?: AbortSignal;
46
+ }): Promise<RiseAgent>;
47
+ update(id: string, patch: AgentPatch, opts?: {
48
+ signal?: AbortSignal;
49
+ }): Promise<RiseAgent>;
50
+ delete(id: string, opts?: {
51
+ signal?: AbortSignal;
52
+ }): Promise<void>;
53
+ run(args: RunAgentArgs): AsyncIterable<AgentRunEvent>;
54
+ createChat(args: {
55
+ agentId: string;
56
+ chatId?: string;
57
+ sessionId?: string;
58
+ }): AgentChatSession;
59
+ listChats(args?: ListChatsArgs): Promise<AgentChatPage>;
60
+ getChat(id: string, opts?: {
61
+ signal?: AbortSignal;
62
+ }): Promise<AgentChatRecord>;
63
+ renameChat(id: string, title: string, opts?: {
64
+ signal?: AbortSignal;
65
+ }): Promise<AgentChatRecord>;
66
+ deleteChat(id: string, opts?: {
67
+ signal?: AbortSignal;
68
+ }): Promise<void>;
69
+ getChatMessages(id: string, args?: GetChatMessagesArgs): Promise<AgentChatMessagePage>;
70
+ }
71
+ export declare function agentMessageText(event: AgentRunEvent): string | null;
72
+ export declare function agentEndReason(event: AgentRunEvent): AgentRunEndReason | null;
73
+ export declare function agentErrorText(event: AgentRunEvent): string | null;
74
+ export interface AgentReplyState {
75
+ text: string;
76
+ delta: string;
77
+ done: boolean;
78
+ reason: AgentRunEndReason | null;
79
+ error: string | null;
80
+ chatId: string | undefined;
81
+ }
82
+ export declare function streamAgentReply(events: AsyncIterable<AgentRunEvent>): AsyncIterable<AgentReplyState>;
83
+ export declare function collectAgentReply(events: AsyncIterable<AgentRunEvent>): Promise<AgentReplyState>;
84
+ export declare function createAgentsConnector(deps?: ConnectorDeps): AgentsConnector;
85
+ export declare const agents: AgentsConnector;