@amodalai/amodal 0.1.7 → 0.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amodalai/amodal",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Amodal CLI",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,11 +30,11 @@
30
30
  "semver": "^7.6.0",
31
31
  "yargs": "^17.7.2",
32
32
  "zod": "^4.3.6",
33
- "@amodalai/core": "0.1.7",
34
- "@amodalai/runtime": "0.1.7"
33
+ "@amodalai/runtime": "0.1.9",
34
+ "@amodalai/core": "0.1.9"
35
35
  },
36
36
  "peerDependencies": {
37
- "@amodalai/runtime-app": "0.1.7"
37
+ "@amodalai/runtime-app": "0.1.9"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@amodalai/runtime-app": {
@@ -100,11 +100,33 @@ export async function runChat(options: ChatOptions): Promise<void> {
100
100
  }
101
101
  }
102
102
 
103
+ // Resolve "latest" to an actual session ID
104
+ let resumeId = options.resume;
105
+ if (resumeId === 'latest') {
106
+ try {
107
+ const res = await fetch(`${baseUrl}/sessions`);
108
+ if (res.ok) {
109
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
110
+ const body = await res.json() as {sessions: Array<{id: string}>};
111
+ if (body.sessions.length > 0) {
112
+ resumeId = body.sessions[0].id;
113
+ process.stderr.write(`[chat] Resuming session ${resumeId}\n`);
114
+ } else {
115
+ process.stderr.write('[chat] No previous sessions found, starting fresh\n');
116
+ resumeId = undefined;
117
+ }
118
+ }
119
+ } catch {
120
+ process.stderr.write('[chat] Could not fetch sessions, starting fresh\n');
121
+ resumeId = undefined;
122
+ }
123
+ }
124
+
103
125
  const {waitUntilExit} = render(
104
126
  createElement(ChatApp, {
105
127
  baseUrl,
106
128
  tenantId,
107
- resumeSessionId: options.resume,
129
+ resumeSessionId: resumeId,
108
130
  fullscreen: options.fullscreen,
109
131
  }),
110
132
  );
@@ -12,19 +12,11 @@ import {createLocalServer} from '@amodalai/runtime';
12
12
  import {findRepoRoot} from '../shared/repo-discovery.js';
13
13
  import {runConnectionPreflight, printPreflightTable} from '../shared/connection-preflight.js';
14
14
 
15
- async function loadRuntimeApp(): Promise<typeof import('@amodalai/runtime-app/dev') | null> {
16
- try {
17
- return await import('@amodalai/runtime-app/dev');
18
- } catch {
19
- // Runtime app is optional — server-only mode without the frontend
20
- return null;
21
- }
22
- }
23
-
24
15
  export interface DevOptions {
25
16
  cwd?: string;
26
17
  port?: number;
27
18
  host?: string;
19
+ resume?: string;
28
20
  }
29
21
 
30
22
  const DEFAULT_PORT = 3847;
@@ -48,29 +40,22 @@ export async function runDev(options: DevOptions = {}): Promise<void> {
48
40
  process.stderr.write(`[dev] Starting dev server for ${repoPath}\n`);
49
41
 
50
42
  try {
51
- // Try to load the runtime app for the dev UI
52
- let appMiddleware: ((req: unknown, res: unknown, next: unknown) => void) | undefined;
53
43
  let staticAppDir: string | undefined;
54
44
 
55
- const runtimeApp = await loadRuntimeApp();
56
- if (runtimeApp) {
57
- process.stderr.write('[dev] Loading runtime app (Vite dev server)...\n');
58
- appMiddleware = await runtimeApp.createDevMiddleware(repoPath);
59
- } else {
60
- // Fall back to pre-built static assets (bundled mode or global install)
61
- const scriptDir = path.dirname(fileURLToPath(import.meta.url));
62
- const candidates = [
63
- // esbuild bundle: bundle/app/
64
- path.resolve(scriptDir, 'app'),
65
- // global/local install: <pkg root>/node_modules/@amodalai/runtime-app/dist/
66
- path.resolve(scriptDir, '..', '..', '..', 'node_modules', '@amodal', 'runtime-app', 'dist'),
67
- ];
68
- for (const dir of candidates) {
69
- if (existsSync(path.join(dir, 'index.html'))) {
70
- process.stderr.write('[dev] Serving pre-built runtime app\n');
71
- staticAppDir = dir;
72
- break;
73
- }
45
+ // Use pre-built static assets for the SPA for the SPA.
46
+ // Vite dev middleware is only used inside the monorepo with `pnpm dev`.
47
+ const scriptDir = path.dirname(fileURLToPath(import.meta.url));
48
+ const candidates = [
49
+ // esbuild bundle: bundle/app/
50
+ path.resolve(scriptDir, 'app'),
51
+ // global/local install: <pkg root>/node_modules/@amodalai/runtime-app/dist/
52
+ path.resolve(scriptDir, '..', '..', '..', 'node_modules', '@amodalai', 'runtime-app', 'dist'),
53
+ ];
54
+ for (const dir of candidates) {
55
+ if (existsSync(path.join(dir, 'index.html'))) {
56
+ process.stderr.write('[dev] Serving pre-built runtime app\n');
57
+ staticAppDir = dir;
58
+ break;
74
59
  }
75
60
  }
76
61
 
@@ -80,8 +65,8 @@ export async function runDev(options: DevOptions = {}): Promise<void> {
80
65
  host,
81
66
  hotReload: true,
82
67
  corsOrigin: '*',
83
- appMiddleware,
84
68
  staticAppDir,
69
+ resumeSessionId: options.resume,
85
70
  });
86
71
 
87
72
  await server.start();
@@ -125,12 +110,18 @@ export const devCommand: CommandModule = {
125
110
  type: 'string',
126
111
  describe: 'Host to bind to',
127
112
  },
113
+ resume: {
114
+ type: 'string',
115
+ describe: 'Resume a previous session by ID or "latest"',
116
+ },
128
117
  },
129
118
  handler: async (argv) => {
130
119
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
131
120
  const port = argv['port'] as number | undefined;
132
121
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
133
122
  const host = argv['host'] as string | undefined;
134
- await runDev({port, host});
123
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
124
+ const resume = argv['resume'] as string | undefined;
125
+ await runDev({port, host, resume});
135
126
  },
136
127
  };