@almadar/workspace 0.4.1 → 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.
@@ -8,4 +8,7 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  import type { OpenWorkspaceOptions, WorkspaceService } from './types.js';
11
+ export declare function openWorkspace(opts: OpenWorkspaceOptions & {
12
+ create: false;
13
+ }): Promise<WorkspaceService | null>;
11
14
  export declare function openWorkspace(opts: OpenWorkspaceOptions): Promise<WorkspaceService>;
package/dist/types.d.ts CHANGED
@@ -178,6 +178,16 @@ export interface OpenWorkspaceOptions {
178
178
  github?: GitHubConfig;
179
179
  /** Fallback fetcher used when the local cache misses. */
180
180
  restore?: RestoreBackend;
181
+ /**
182
+ * When `false`, open is a pure read: resolve an EXISTING workspace (local
183
+ * resume, or restore that actually yields files) but NEVER mint a fresh one.
184
+ * Returns `null` when the appId exists in neither the local cache nor the
185
+ * restore backend — so callers can 404 instead of silently creating (and
186
+ * listing) a phantom workspace. Defaults to `true` (mint on miss, the
187
+ * historical behaviour). A `github`-clone-on-miss still requires
188
+ * `create !== false` (remote existence can't be verified without cloning).
189
+ */
190
+ create?: boolean;
181
191
  /** Storage selector. `'memory'` is for tests; `'local'` is default. */
182
192
  backend?: 'local' | 'memory';
183
193
  /** Optional project name baked into the mint-time schema template. */
@@ -316,6 +326,18 @@ export interface AccountConfig {
316
326
  export interface ProviderCredential {
317
327
  apiKey: string;
318
328
  }
329
+ /**
330
+ * Hosted-builder auth token, persisted to `~/.almadar/auth.json` (chmod 600).
331
+ * The Firebase ID token the local server / sync sends to the hosted builder for
332
+ * the signed-in ("studio") account. Distinct from {@link ProviderCredential}
333
+ * (BYO LLM key) and {@link AccountIdentity} (non-secret uid/email overlay).
334
+ */
335
+ export interface AuthToken {
336
+ token: string;
337
+ refreshToken?: string;
338
+ /** ISO expiry of the ID token (~1h from issue). */
339
+ expiresAt?: string;
340
+ }
319
341
  /** Studio-synced identity overlay, persisted to `~/.almadar/account.json`. Empty until login. */
320
342
  export interface AccountIdentity {
321
343
  uid: string;
@@ -345,13 +367,23 @@ export interface AccountService {
345
367
  listCredentialedProviders(): Promise<string[]>;
346
368
  readAccount(): Promise<AccountIdentity | null>;
347
369
  writeAccount(identity: AccountIdentity): Promise<void>;
370
+ /** Read the stored hosted-builder auth token, or null when signed out. */
371
+ getAuthToken(): Promise<AuthToken | null>;
372
+ /** Persist the hosted-builder auth token (chmod 600). */
373
+ setAuthToken(token: AuthToken): Promise<void>;
374
+ /** Remove the stored auth token (sign out). Idempotent. */
375
+ clearAuthToken(): Promise<void>;
348
376
  /**
349
377
  * Resolve the explicit {@link ProviderConfig} for `provider` (stored apiKey +
350
378
  * config baseUrl/model overrides), ready to pass into `@almadar/llm` / rabit.
351
379
  * Returns null when no credential is stored for `provider`.
352
380
  */
353
381
  resolveProviderConfig(provider: string): Promise<ProviderConfig | null>;
354
- /** True once setup completed AND at least one provider has a stored credential. */
382
+ /**
383
+ * True once setup completed AND the account can actually run AI — either a
384
+ * stored provider credential (BYO-key) or a hosted-builder auth token
385
+ * (signed-in studio account).
386
+ */
355
387
  isConfigured(): Promise<boolean>;
356
388
  dispose(): Promise<void>;
357
389
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/workspace",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "Storage-agnostic workspace primitives shared by Almadar consumers. One service, six exports, hidden paths, single observer. See docs/Almadar_Workspace.md.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",