@almadar/workspace 0.5.0 → 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.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -10,6 +10,6 @@ export { openWorkspace } from './open-workspace.js';
10
10
  export { listWorkspaces } from './list-workspaces.js';
11
11
  export { deleteWorkspace } from './delete-workspace.js';
12
12
  export { openAccount } from './account.js';
13
- export type { WorkspaceService, WorkspaceObserver, WorkspaceWriteEvent, WorkspaceWatchEvent, OpenWorkspaceOptions, ListWorkspacesOptions, WorkspaceSummary, RestoreBackend, GitHubConfig, GitStatusInfo, FileTreeNode, AccountService, AccountConfig, ProviderCredential, AccountIdentity, OpenAccountOptions, } from './types.js';
13
+ export type { WorkspaceService, WorkspaceObserver, WorkspaceWriteEvent, WorkspaceWatchEvent, OpenWorkspaceOptions, ListWorkspacesOptions, WorkspaceSummary, RestoreBackend, GitHubConfig, GitStatusInfo, FileTreeNode, AccountService, AccountConfig, ProviderCredential, AuthToken, AccountIdentity, OpenAccountOptions, } from './types.js';
14
14
  export type { WorkspaceIndex, EmbedderPort, ResolveResult, ResolveOptions, TraitRefEmit, WorkspaceIndexStats, OrbitalIndexEntry, ExtraTraitIdentity, RetrievalResult, RetrievalOptions, RecentlyEditedOptions, EventEdge, EntityBinding, RuleBinding, RecencyEntry, IntentMaps, ComposedMaps, BM25Document, BM25Table, BM25Options, WorkspaceIndexManifest, } from './workspace-index/types.js';
15
15
  export { DEFAULT_COERCION_THRESHOLD, DEFAULT_RETRIEVAL_TOP_K, RRF_K, WORKSPACE_INDEX_SCHEMA_VERSION, } from './workspace-index/types.js';
package/dist/index.js CHANGED
@@ -2338,6 +2338,7 @@ var ACCOUNT_DIR = ".almadar";
2338
2338
  var CONFIG_FILE = "config.json";
2339
2339
  var CREDENTIALS_FILE = "credentials.json";
2340
2340
  var ACCOUNT_FILE = "account.json";
2341
+ var AUTH_FILE = "auth.json";
2341
2342
  var SECRET_MODE = 384;
2342
2343
  var DEFAULT_CONFIG = {
2343
2344
  schemaVersion: 1,
@@ -2395,6 +2396,18 @@ async function openAccount(opts = {}) {
2395
2396
  async writeAccount(identity) {
2396
2397
  await backend.writeFile(file(ACCOUNT_FILE), JSON.stringify(identity, null, 2));
2397
2398
  },
2399
+ async getAuthToken() {
2400
+ return readJson(AUTH_FILE);
2401
+ },
2402
+ async setAuthToken(token) {
2403
+ const p = file(AUTH_FILE);
2404
+ await backend.writeFile(p, JSON.stringify(token, null, 2));
2405
+ await backend.chmod(p, SECRET_MODE);
2406
+ },
2407
+ async clearAuthToken() {
2408
+ const p = file(AUTH_FILE);
2409
+ if (backend.exists(p)) await backend.rm(p);
2410
+ },
2398
2411
  async resolveProviderConfig(provider) {
2399
2412
  const creds = await readCredentials();
2400
2413
  const cred = creds[provider];
@@ -2410,7 +2423,8 @@ async function openAccount(opts = {}) {
2410
2423
  async isConfigured() {
2411
2424
  const cfg = await getConfig();
2412
2425
  if (!cfg.setupCompletedAt) return false;
2413
- return Object.keys(await readCredentials()).length > 0;
2426
+ if (Object.keys(await readCredentials()).length > 0) return true;
2427
+ return await readJson(AUTH_FILE) !== null;
2414
2428
  },
2415
2429
  async dispose() {
2416
2430
  }