@almadar/workspace 0.5.0 → 0.7.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.
- package/dist/__tests__/account-auth-token.test.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +25 -1
- package/package.json +1 -1
|
@@ -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,
|
|
@@ -2389,12 +2390,30 @@ async function openAccount(opts = {}) {
|
|
|
2389
2390
|
async listCredentialedProviders() {
|
|
2390
2391
|
return Object.keys(await readCredentials());
|
|
2391
2392
|
},
|
|
2393
|
+
async clearCredential(provider) {
|
|
2394
|
+
const creds = await readCredentials();
|
|
2395
|
+
if (!(provider in creds)) return;
|
|
2396
|
+
delete creds[provider];
|
|
2397
|
+
await writeCredentials(creds);
|
|
2398
|
+
},
|
|
2392
2399
|
async readAccount() {
|
|
2393
2400
|
return readJson(ACCOUNT_FILE);
|
|
2394
2401
|
},
|
|
2395
2402
|
async writeAccount(identity) {
|
|
2396
2403
|
await backend.writeFile(file(ACCOUNT_FILE), JSON.stringify(identity, null, 2));
|
|
2397
2404
|
},
|
|
2405
|
+
async getAuthToken() {
|
|
2406
|
+
return readJson(AUTH_FILE);
|
|
2407
|
+
},
|
|
2408
|
+
async setAuthToken(token) {
|
|
2409
|
+
const p = file(AUTH_FILE);
|
|
2410
|
+
await backend.writeFile(p, JSON.stringify(token, null, 2));
|
|
2411
|
+
await backend.chmod(p, SECRET_MODE);
|
|
2412
|
+
},
|
|
2413
|
+
async clearAuthToken() {
|
|
2414
|
+
const p = file(AUTH_FILE);
|
|
2415
|
+
if (backend.exists(p)) await backend.rm(p);
|
|
2416
|
+
},
|
|
2398
2417
|
async resolveProviderConfig(provider) {
|
|
2399
2418
|
const creds = await readCredentials();
|
|
2400
2419
|
const cred = creds[provider];
|
|
@@ -2410,7 +2429,8 @@ async function openAccount(opts = {}) {
|
|
|
2410
2429
|
async isConfigured() {
|
|
2411
2430
|
const cfg = await getConfig();
|
|
2412
2431
|
if (!cfg.setupCompletedAt) return false;
|
|
2413
|
-
|
|
2432
|
+
if (Object.keys(await readCredentials()).length > 0) return true;
|
|
2433
|
+
return await readJson(AUTH_FILE) !== null;
|
|
2414
2434
|
},
|
|
2415
2435
|
async dispose() {
|
|
2416
2436
|
}
|