@almadar/workspace 0.2.4 → 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.
- package/dist/account.d.ts +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +91 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/backends/local.d.ts +1 -0
- package/dist/internal/backends/memory.d.ts +1 -0
- package/dist/internal/types.d.ts +2 -0
- package/dist/types.d.ts +70 -0
- package/package.json +2 -2
package/dist/internal/types.d.ts
CHANGED
|
@@ -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.
|
|
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",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"license": "BUSL-1.1",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@almadar/core": "
|
|
28
|
+
"@almadar/core": ">=9.6.1",
|
|
29
29
|
"@almadar/llm": "^2.16.0",
|
|
30
30
|
"typescript": "^5.4.0"
|
|
31
31
|
},
|