@almadar/workspace 0.2.5 → 0.2.6

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.
@@ -20,4 +20,5 @@ export declare class LocalBackend implements WorkspaceBackend {
20
20
  isDirectory: boolean;
21
21
  }>;
22
22
  rename(srcAbs: string, dstAbs: string): Promise<void>;
23
+ chmod(absPath: string, mode: number): Promise<void>;
23
24
  }
@@ -21,6 +21,7 @@ export declare class MemoryBackend implements WorkspaceBackend {
21
21
  isDirectory: boolean;
22
22
  }>;
23
23
  rename(srcAbs: string, dstAbs: string): Promise<void>;
24
+ chmod(): Promise<void>;
24
25
  getAll(): Map<string, string>;
25
26
  clear(): void;
26
27
  }
@@ -35,6 +35,8 @@ export interface WorkspaceBackend {
35
35
  * exists; backend ensures `dstAbs`'s parent dir exists before move.
36
36
  */
37
37
  rename(srcAbs: string, dstAbs: string): Promise<void>;
38
+ /** Set file mode bits (e.g. `0o600` for a secrets file). No-op on backends without a real fs. */
39
+ chmod(absPath: string, mode: number): Promise<void>;
38
40
  }
39
41
  /**
40
42
  * The persisted marker that pins an `appId` to a workspace dir on disk.
package/dist/types.d.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  * @packageDocumentation
8
8
  */
9
9
  import type { JsonObject, JsonValue } from '@almadar/core';
10
+ import type { ProviderConfig } from '@almadar/llm';
10
11
  import type { EmbedderPort, WorkspaceIndex } from './workspace-index/types.js';
11
12
  /**
12
13
  * The only extension point. Consumers register one observer via
@@ -236,3 +237,72 @@ export interface WorkspaceService {
236
237
  readonly index: WorkspaceIndex;
237
238
  dispose(): Promise<void>;
238
239
  }
240
+ /**
241
+ * Non-secret account config, persisted to `~/.almadar/config.json`. Safe to
242
+ * inspect/sync. Secrets live in `credentials.json` (see {@link ProviderCredential}).
243
+ */
244
+ export interface AccountConfig {
245
+ schemaVersion: 1;
246
+ /** ISO timestamp; absence signals the first-run setup hasn't completed. */
247
+ setupCompletedAt?: string;
248
+ defaultProvider: string;
249
+ defaultModel: string;
250
+ autonomy: 'full' | 'balanced' | 'cautious';
251
+ budget?: number;
252
+ /** Per-provider non-secret overrides, keyed by provider name. */
253
+ providers?: Record<string, {
254
+ baseUrl?: string;
255
+ model?: string;
256
+ }>;
257
+ /** Service endpoints (override the built-in defaults). */
258
+ services?: {
259
+ authUrl?: string;
260
+ builderUrl?: string;
261
+ masarUrl?: string;
262
+ };
263
+ /** Where the active config came from. */
264
+ source: 'local' | 'studio';
265
+ }
266
+ /** A single provider's secret, persisted to `~/.almadar/credentials.json` (chmod 600). */
267
+ export interface ProviderCredential {
268
+ apiKey: string;
269
+ }
270
+ /** Studio-synced identity overlay, persisted to `~/.almadar/account.json`. Empty until login. */
271
+ export interface AccountIdentity {
272
+ uid: string;
273
+ email?: string;
274
+ tier?: string;
275
+ teamId?: string | null;
276
+ syncedAt: string;
277
+ }
278
+ export interface OpenAccountOptions {
279
+ /** Home directory root. Defaults to `os.homedir()`. */
280
+ home?: string;
281
+ /** Storage backend. Defaults to `'local'` (real filesystem). */
282
+ backend?: 'local' | 'memory';
283
+ }
284
+ /**
285
+ * Account-level store rooted at `~/.almadar/`. Home-rooted and NOT sandboxed
286
+ * (unlike {@link WorkspaceService}); owns config + credentials + the Studio
287
+ * identity overlay. Construct via `openAccount`.
288
+ */
289
+ export interface AccountService {
290
+ /** Absolute `~/.almadar` path. */
291
+ readonly root: string;
292
+ getConfig(): Promise<AccountConfig>;
293
+ setConfig(patch: Partial<AccountConfig>): Promise<void>;
294
+ getCredential(provider: string): Promise<ProviderCredential | null>;
295
+ setCredential(provider: string, cred: ProviderCredential): Promise<void>;
296
+ listCredentialedProviders(): Promise<string[]>;
297
+ readAccount(): Promise<AccountIdentity | null>;
298
+ writeAccount(identity: AccountIdentity): Promise<void>;
299
+ /**
300
+ * Resolve the explicit {@link ProviderConfig} for `provider` (stored apiKey +
301
+ * config baseUrl/model overrides), ready to pass into `@almadar/llm` / rabit.
302
+ * Returns null when no credential is stored for `provider`.
303
+ */
304
+ resolveProviderConfig(provider: string): Promise<ProviderConfig | null>;
305
+ /** True once setup completed AND at least one provider has a stored credential. */
306
+ isConfigured(): Promise<boolean>;
307
+ dispose(): Promise<void>;
308
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/workspace",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
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",