@doist/outline-cli 1.8.0 → 1.9.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/commands/account.d.ts +2 -0
  3. package/dist/commands/account.js +107 -0
  4. package/dist/commands/account.js.map +1 -0
  5. package/dist/commands/auth.d.ts +0 -12
  6. package/dist/commands/auth.js +15 -26
  7. package/dist/commands/auth.js.map +1 -1
  8. package/dist/index.js +19 -4
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/api.js +20 -9
  11. package/dist/lib/api.js.map +1 -1
  12. package/dist/lib/auth-output.d.ts +15 -0
  13. package/dist/lib/auth-output.js +27 -0
  14. package/dist/lib/auth-output.js.map +1 -0
  15. package/dist/lib/auth-provider.d.ts +26 -18
  16. package/dist/lib/auth-provider.js +47 -19
  17. package/dist/lib/auth-provider.js.map +1 -1
  18. package/dist/lib/auth.d.ts +32 -11
  19. package/dist/lib/auth.js +54 -13
  20. package/dist/lib/auth.js.map +1 -1
  21. package/dist/lib/errors.d.ts +1 -1
  22. package/dist/lib/errors.js.map +1 -1
  23. package/dist/lib/global-args.d.ts +25 -0
  24. package/dist/lib/global-args.js +50 -1
  25. package/dist/lib/global-args.js.map +1 -1
  26. package/dist/lib/outline-account.d.ts +7 -1
  27. package/dist/lib/outline-account.js +10 -0
  28. package/dist/lib/outline-account.js.map +1 -1
  29. package/dist/lib/skills/content.d.ts +1 -1
  30. package/dist/lib/skills/content.js +18 -0
  31. package/dist/lib/skills/content.js.map +1 -1
  32. package/dist/lib/user-records.d.ts +8 -1
  33. package/dist/lib/user-records.js +17 -1
  34. package/dist/lib/user-records.js.map +1 -1
  35. package/dist/lib/user-ref-store.d.ts +16 -0
  36. package/dist/lib/user-ref-store.js +37 -0
  37. package/dist/lib/user-ref-store.js.map +1 -0
  38. package/package.json +2 -2
@@ -6,8 +6,9 @@ import { LEGACY_CLEAR_PAYLOAD, SECURE_STORE_SERVICE, TOKEN_ENV_VAR } from './aut
6
6
  import { getBaseUrl, getOAuthClientId } from './auth.js';
7
7
  import { getConfig, getConfigPath, updateConfig } from './config.js';
8
8
  import { runMigrateLegacyAuth } from './migrate-auth.js';
9
- import { makeOutlineAccount } from './outline-account.js';
10
- import { createOutlineUserRecordStore, getDefaultUserRecord } from './user-records.js';
9
+ import { makeOutlineAccount, matchOutlineAccount } from './outline-account.js';
10
+ import { createOutlineUserRecordStore, getDefaultUserRecord, recordForRef } from './user-records.js';
11
+ export { matchOutlineAccount } from './outline-account.js';
11
12
  function stringFlag(flags, key) {
12
13
  const value = flags[key];
13
14
  return typeof value === 'string' && value.trim() ? value.trim() : undefined;
@@ -95,16 +96,6 @@ export function createOutlineAuthProvider() {
95
96
  fetchImpl: outlineFetch,
96
97
  });
97
98
  }
98
- /**
99
- * Accepts the Outline user UUID or display name. Id matches are
100
- * case-sensitive (UUIDs are canonical); label matches are
101
- * case-insensitive so users can pass the name they see in `auth status`.
102
- */
103
- export function matchOutlineAccount(account, ref) {
104
- if (account.id === ref)
105
- return true;
106
- return account.label.toLowerCase() === ref.toLowerCase();
107
- }
108
99
  /** True when the v2 store is the authoritative source. */
109
100
  function migrationIsConclusive(result) {
110
101
  return (result.status === 'migrated' ||
@@ -190,13 +181,41 @@ export async function isLegacyAuthActive() {
190
181
  * propagates it so a failed logout fails loudly instead of leaving the
191
182
  * user authenticated via the legacy fallback.
192
183
  */
193
- export function createOutlineTokenStore() {
194
- const inner = createKeyringTokenStore({
184
+ /** The bare cli-core keyring store (v2 records only — no env/legacy fallback). */
185
+ function createInnerStore() {
186
+ return createKeyringTokenStore({
195
187
  serviceName: SECURE_STORE_SERVICE,
196
188
  userRecords: createOutlineUserRecordStore(),
197
189
  recordsLocation: getConfigPath(),
198
190
  matchAccount: matchOutlineAccount,
199
191
  });
192
+ }
193
+ /**
194
+ * Authoritatively classify the active credential without re-deriving the
195
+ * cascade from membership heuristics. Mirrors `active()`'s precedence — env
196
+ * (only when no explicit ref) → stored v2 → legacy snapshot — but reports
197
+ * *which* branch matched, so `ol account current` can render the right shape.
198
+ *
199
+ * The v2 lookup uses the bare keyring store (no legacy fallback) and matches by
200
+ * `ref`, so a renamed legacy snapshot sharing a UUID with a v2 record can't be
201
+ * misreported as `stored`: a `--user <old-name>` that the v2 record no longer
202
+ * matches falls through to the legacy branch.
203
+ */
204
+ export async function resolveActiveAccountSource(ref) {
205
+ if (ref === undefined && process.env[TOKEN_ENV_VAR]?.trim())
206
+ return { source: 'env' };
207
+ await ensureMigrated();
208
+ const stored = await createInnerStore().activeAccount(ref);
209
+ if (stored)
210
+ return { source: 'stored', account: stored.account, isDefault: stored.isDefault };
211
+ const legacy = await readLegacyTokenSnapshot();
212
+ if (legacy && (ref === undefined || matchOutlineAccount(legacy.account, ref))) {
213
+ return { source: 'legacy' };
214
+ }
215
+ return null;
216
+ }
217
+ export function createOutlineTokenStore() {
218
+ const inner = createInnerStore();
200
219
  async function migrationIsInconclusive() {
201
220
  const result = await ensureMigrated(); // memoised
202
221
  return result === null || !migrationIsConclusive(result);
@@ -239,6 +258,9 @@ export function createOutlineTokenStore() {
239
258
  active(ref) {
240
259
  return resolveAuth(ref, () => inner.active(ref), (token, account) => ({ token, account }));
241
260
  },
261
+ activeAccount(ref) {
262
+ return resolveAuth(ref, () => inner.activeAccount(ref), (_token, account) => ({ account, isDefault: true }));
263
+ },
242
264
  activeBundle(ref) {
243
265
  return resolveAuth(ref, () => inner.activeBundle(ref), (token, account) => ({ account, bundle: { accessToken: token } }));
244
266
  },
@@ -250,12 +272,13 @@ export function createOutlineTokenStore() {
250
272
  },
251
273
  async clear(ref) {
252
274
  await ensureMigrated();
253
- await inner.clear(ref);
275
+ const cleared = await inner.clear(ref);
254
276
  if (await migrationIsInconclusive()) {
255
277
  // Must succeed: v2 is now empty, so a surviving legacy
256
278
  // token would shadow the logout via the fallback.
257
279
  await dischargeLegacyState();
258
280
  }
281
+ return cleared;
259
282
  },
260
283
  async list() {
261
284
  await ensureMigrated();
@@ -274,6 +297,11 @@ export function createOutlineTokenStore() {
274
297
  * order — env → v2 record → legacy plaintext — so the answer can never
275
298
  * contradict the token the runtime is actually using.
276
299
  *
300
+ * Pass `ref` to report the source of a specific `--user` account (used by
301
+ * `auth status --user <ref>`): a ref selects the matching record and skips the
302
+ * env short-circuit, so the source reflects the account being shown rather
303
+ * than an ambient env token. Without a ref the default/env cascade applies.
304
+ *
277
305
  * The precedence cascade is intentionally duplicated with `active()`:
278
306
  * the only true dedupe options either (a) add an extra config read on
279
307
  * every `apiRequest` call (regressing the request hot path) or (b)
@@ -281,14 +309,14 @@ export function createOutlineTokenStore() {
281
309
  * invites is guarded by the `getActiveTokenSource` regression test that
282
310
  * asserts v2-record presence wins over a lingering v1 `api_token`.
283
311
  */
284
- export async function getActiveTokenSource() {
285
- if (process.env[TOKEN_ENV_VAR]?.trim())
312
+ export async function getActiveTokenSource(ref) {
313
+ if (ref === undefined && process.env[TOKEN_ENV_VAR]?.trim())
286
314
  return 'env';
287
315
  const config = await getConfig();
288
- const record = getDefaultUserRecord(config);
316
+ const record = ref !== undefined ? recordForRef(config, ref) : getDefaultUserRecord(config);
289
317
  if (record)
290
318
  return record.fallbackToken ? 'config-file' : 'secure-store';
291
- if (config.api_token?.trim())
319
+ if (ref === undefined && config.api_token?.trim())
292
320
  return 'config-file';
293
321
  return 'secure-store';
294
322
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth-provider.js","sourceRoot":"","sources":["../../src/lib/auth-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAGH,uBAAuB,EACvB,kBAAkB,GAIrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,aAAa,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,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;IAChC,MAAM,MAAM,GAAG,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAA;IAC3F,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAA;IACxE,IAAI,GAAG,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE;QAAE,OAAO,aAAa,CAAA;IACvE,OAAO,cAAc,CAAA;AACzB,CAAC"}
@@ -3,6 +3,14 @@ import { TOKEN_ENV_VAR } from './auth-constants.js';
3
3
  import { getActiveTokenSource } from './auth-provider.js';
4
4
  import { CliError } from './errors.js';
5
5
  import { type OutlineAccount } from './outline-account.js';
6
+ /** Base URL + optional refresh handshake for a single request. */
7
+ type RequestContext = {
8
+ baseUrl: string;
9
+ handshake?: {
10
+ baseUrl: string;
11
+ clientId: string;
12
+ };
13
+ };
6
14
  export { SecureStoreUnavailableError, getActiveTokenSource, TOKEN_ENV_VAR };
7
15
  export declare class NoTokenError extends CliError {
8
16
  constructor();
@@ -10,11 +18,13 @@ export declare class NoTokenError extends CliError {
10
18
  /**
11
19
  * Best-effort proactive rotation before a request. Returns the token to use
12
20
  * (the rotated one, or the current one if no rotation was needed) so the
13
- * caller doesn't re-read the store; `undefined` when the default account
14
- * isn't refreshable (no refresh token / env / failure) — the caller then
15
- * falls back to `getApiToken()` and the 401 path stays authoritative.
21
+ * caller doesn't re-read the store; `undefined` when the account isn't
22
+ * refreshable (no refresh token / env / failure) — the caller then falls back
23
+ * to `getApiToken()` and the 401 path stays authoritative. The wrapped store
24
+ * scopes the bundle to any global `--user`; `handshake` pins the token
25
+ * endpoint to that account's instance + client id.
16
26
  */
17
- export declare function proactiveRefresh(): Promise<string | undefined>;
27
+ export declare function proactiveRefresh(handshake?: RequestContext['handshake']): Promise<string | undefined>;
18
28
  /**
19
29
  * Refresh the *selected* account (not the default) for `auth status`, returning
20
30
  * its current-or-rotated token. Scoped via the account's id + base URL/client
@@ -28,7 +38,7 @@ export declare function refreshedTokenForStatus(account: OutlineAccount, fallbac
28
38
  * caller retries once). A rejected/absent refresh token surfaces as
29
39
  * `NoTokenError` (re-login); a transient failure propagates unchanged.
30
40
  */
31
- export declare function reactiveRefresh(): Promise<boolean>;
41
+ export declare function reactiveRefresh(handshake?: RequestContext['handshake']): Promise<boolean>;
32
42
  /**
33
43
  * Read the active token. Hot path: when `OUTLINE_API_TOKEN` is set we
34
44
  * return it directly without consulting the token store, since
@@ -38,14 +48,25 @@ export declare function reactiveRefresh(): Promise<boolean>;
38
48
  */
39
49
  export declare function getApiToken(): Promise<string>;
40
50
  /**
41
- * Base URL cascade: env var → default user record (v2) → legacy
42
- * `base_url` config (v1) → built-in default. The record takes priority
43
- * over the legacy slot so post-migration logins keep defaulting to the
44
- * same Outline instance.
51
+ * Account-agnostic base URL cascade: env var → default user record (v2) →
52
+ * legacy `base_url` config (v1) → built-in default. Deliberately ignores the
53
+ * global `--user` selector so the login flow (which resolves its default
54
+ * prompt through here) isn't skewed by account selection; the request path
55
+ * applies `--user` separately via {@link getRequestContext}.
45
56
  */
46
57
  export declare function getBaseUrl(): Promise<string>;
47
58
  /**
48
- * OAuth client id cascade: env var → default user record (v2) → legacy
49
- * `oauth_client_id` config (v1) → undefined (caller prompts).
59
+ * Account-agnostic OAuth client id cascade: env var → default user record
60
+ * (v2) → legacy `oauth_client_id` config (v1) → undefined (caller prompts).
61
+ * Like {@link getBaseUrl}, ignores `--user` so login stays default-driven.
50
62
  */
51
63
  export declare function getOAuthClientId(): Promise<string | undefined>;
64
+ /**
65
+ * Resolve the base URL — and, when a `--user` account is selected, the refresh
66
+ * handshake (its instance + client id) — for a single managed request. Falls
67
+ * back to the account-agnostic {@link getBaseUrl} cascade without `--user`.
68
+ * An unknown ref resolves no handshake and the default base URL; the wrapped
69
+ * token store then raises `ACCOUNT_NOT_FOUND` when the token is read, so the
70
+ * request never fires.
71
+ */
72
+ export declare function getRequestContext(): Promise<RequestContext>;
package/dist/lib/auth.js CHANGED
@@ -3,8 +3,10 @@ import { TOKEN_ENV_VAR } from './auth-constants.js';
3
3
  import { createOutlineAuthProvider, createOutlineTokenStore, getActiveTokenSource, } from './auth-provider.js';
4
4
  import { getConfig, getConfigPath } from './config.js';
5
5
  import { CliError } from './errors.js';
6
+ import { getRequestedUserRef } from './global-args.js';
6
7
  import { DEFAULT_BASE_URL } from './outline-account.js';
7
- import { getDefaultUserRecord } from './user-records.js';
8
+ import { getDefaultUserRecord, recordForRef } from './user-records.js';
9
+ import { withUserRefAware } from './user-ref-store.js';
8
10
  export { SecureStoreUnavailableError, getActiveTokenSource, TOKEN_ENV_VAR };
9
11
  export class NoTokenError extends CliError {
10
12
  constructor() {
@@ -19,10 +21,24 @@ export class NoTokenError extends CliError {
19
21
  */
20
22
  let storeSingleton;
21
23
  function tokenStore() {
24
+ // Wrapped so a global `--user <ref>` flows into every no-ref store read on
25
+ // the request hot path (token lookup + refresh). Without `--user`,
26
+ // `getRequestedUserRef()` is undefined and the wrap is a pass-through.
22
27
  if (!storeSingleton)
23
- storeSingleton = createOutlineTokenStore();
28
+ storeSingleton = withUserRefAware(createOutlineTokenStore());
24
29
  return storeSingleton;
25
30
  }
31
+ /**
32
+ * The `--user` ref to apply on the request path, or `undefined` when an
33
+ * `OUTLINE_API_TOKEN` is set — an env token wins outright, so base URL and
34
+ * client id resolve from the default account rather than the named one,
35
+ * keeping token / base URL / client id pinned to the same source.
36
+ */
37
+ function requestPathUserRef() {
38
+ if (process.env[TOKEN_ENV_VAR]?.trim())
39
+ return undefined;
40
+ return getRequestedUserRef();
41
+ }
26
42
  let providerSingleton;
27
43
  function authProvider() {
28
44
  if (!providerSingleton)
@@ -38,16 +54,19 @@ function refreshLockPath() {
38
54
  /**
39
55
  * Best-effort proactive rotation before a request. Returns the token to use
40
56
  * (the rotated one, or the current one if no rotation was needed) so the
41
- * caller doesn't re-read the store; `undefined` when the default account
42
- * isn't refreshable (no refresh token / env / failure) — the caller then
43
- * falls back to `getApiToken()` and the 401 path stays authoritative.
57
+ * caller doesn't re-read the store; `undefined` when the account isn't
58
+ * refreshable (no refresh token / env / failure) — the caller then falls back
59
+ * to `getApiToken()` and the 401 path stays authoritative. The wrapped store
60
+ * scopes the bundle to any global `--user`; `handshake` pins the token
61
+ * endpoint to that account's instance + client id.
44
62
  */
45
- export async function proactiveRefresh() {
63
+ export async function proactiveRefresh(handshake) {
46
64
  try {
47
65
  const { bundle } = await refreshAccessToken({
48
66
  store: tokenStore(),
49
67
  provider: authProvider(),
50
68
  lockPath: refreshLockPath(),
69
+ handshake,
51
70
  });
52
71
  return bundle.accessToken;
53
72
  }
@@ -84,13 +103,14 @@ export async function refreshedTokenForStatus(account, fallback) {
84
103
  * caller retries once). A rejected/absent refresh token surfaces as
85
104
  * `NoTokenError` (re-login); a transient failure propagates unchanged.
86
105
  */
87
- export async function reactiveRefresh() {
106
+ export async function reactiveRefresh(handshake) {
88
107
  try {
89
108
  const result = await refreshAccessToken({
90
109
  store: tokenStore(),
91
110
  provider: authProvider(),
92
111
  lockPath: refreshLockPath(),
93
112
  force: true,
113
+ handshake,
94
114
  });
95
115
  return result.rotated;
96
116
  }
@@ -122,10 +142,11 @@ export async function getApiToken() {
122
142
  return snapshot.token;
123
143
  }
124
144
  /**
125
- * Base URL cascade: env var → default user record (v2) → legacy
126
- * `base_url` config (v1) → built-in default. The record takes priority
127
- * over the legacy slot so post-migration logins keep defaulting to the
128
- * same Outline instance.
145
+ * Account-agnostic base URL cascade: env var → default user record (v2) →
146
+ * legacy `base_url` config (v1) → built-in default. Deliberately ignores the
147
+ * global `--user` selector so the login flow (which resolves its default
148
+ * prompt through here) isn't skewed by account selection; the request path
149
+ * applies `--user` separately via {@link getRequestContext}.
129
150
  */
130
151
  export async function getBaseUrl() {
131
152
  const envUrl = process.env.OUTLINE_URL;
@@ -140,8 +161,9 @@ export async function getBaseUrl() {
140
161
  return DEFAULT_BASE_URL;
141
162
  }
142
163
  /**
143
- * OAuth client id cascade: env var → default user record (v2) → legacy
144
- * `oauth_client_id` config (v1) → undefined (caller prompts).
164
+ * Account-agnostic OAuth client id cascade: env var → default user record
165
+ * (v2) → legacy `oauth_client_id` config (v1) → undefined (caller prompts).
166
+ * Like {@link getBaseUrl}, ignores `--user` so login stays default-driven.
145
167
  */
146
168
  export async function getOAuthClientId() {
147
169
  const envClientId = process.env.OUTLINE_OAUTH_CLIENT_ID;
@@ -153,4 +175,23 @@ export async function getOAuthClientId() {
153
175
  return record.account.oauthClientId;
154
176
  return config.oauth_client_id;
155
177
  }
178
+ /**
179
+ * Resolve the base URL — and, when a `--user` account is selected, the refresh
180
+ * handshake (its instance + client id) — for a single managed request. Falls
181
+ * back to the account-agnostic {@link getBaseUrl} cascade without `--user`.
182
+ * An unknown ref resolves no handshake and the default base URL; the wrapped
183
+ * token store then raises `ACCOUNT_NOT_FOUND` when the token is read, so the
184
+ * request never fires.
185
+ */
186
+ export async function getRequestContext() {
187
+ const ref = requestPathUserRef();
188
+ if (ref !== undefined) {
189
+ const record = recordForRef(await getConfig(), ref);
190
+ if (record) {
191
+ const baseUrl = record.account.baseUrl.replace(/\/$/, '');
192
+ return { baseUrl, handshake: { baseUrl, clientId: record.account.oauthClientId } };
193
+ }
194
+ }
195
+ return { baseUrl: await getBaseUrl() };
196
+ }
156
197
  //# sourceMappingURL=auth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EACH,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,GAEvB,MAAM,oBAAo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IAAI,MAAM,EAAE,CAAC;YACT,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;YACzD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAA;QACtF,CAAC;IACL,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,EAAE,EAAE,CAAA;AAC1C,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { CliError as CoreCliError, type CliErrorCode, type ErrorType } from '@doist/cli-core';
2
2
  export { CoreCliError as BaseCliError };
3
3
  export type { ErrorType } from '@doist/cli-core';
4
- export type ErrorCode = 'ACCOUNT_NOT_FOUND' | 'AUTH_VERIFICATION_FAILED' | 'CONFIRMATION_REQUIRED' | 'CONFLICTING_OPTIONS' | 'INVALID_PARENT' | 'MISSING_OPTION' | 'NO_TOKEN' | 'OAUTH_CALLBACK_PORT_INVALID' | 'OAUTH_CALLBACK_SERVER_FAILED' | 'OAUTH_CLIENT_ID_REQUIRED' | 'OAUTH_LOGIN_FAILED' | 'UNKNOWN_AGENT';
4
+ export type ErrorCode = 'ACCOUNT_NOT_FOUND' | 'AUTH_VERIFICATION_FAILED' | 'CONFIRMATION_REQUIRED' | 'CONFLICTING_OPTIONS' | 'INVALID_PARENT' | 'INVALID_USER_FLAG' | 'MISSING_OPTION' | 'NO_TOKEN' | 'OAUTH_CALLBACK_PORT_INVALID' | 'OAUTH_CALLBACK_SERVER_FAILED' | 'OAUTH_CLIENT_ID_REQUIRED' | 'OAUTH_LOGIN_FAILED' | 'UNKNOWN_AGENT';
5
5
  export declare class CliError extends CoreCliError<ErrorCode> {
6
6
  constructor(code: ErrorCode | CliErrorCode, message: string, hints?: string[], type?: ErrorType);
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAqC,MAAM,iBAAiB,CAAA;AAE7F,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,CAAA;AAiBvC,MAAM,OAAO,QAAS,SAAQ,YAAuB;IACjD,YACI,IAA8B,EAC9B,OAAe,EACf,KAAgB,EAChB,OAAkB,OAAO;QAEzB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACzC,CAAC;CACJ;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAqC,MAAM,iBAAiB,CAAA;AAE7F,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,CAAA;AAkBvC,MAAM,OAAO,QAAS,SAAQ,YAAuB;IACjD,YACI,IAA8B,EAC9B,OAAe,EACf,KAAgB,EAChB,OAAkB,OAAO;QAEzB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACzC,CAAC;CACJ;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA"}
@@ -3,3 +3,28 @@ export declare const resetGlobalArgs: () => void;
3
3
  export declare const isAccessible: () => boolean;
4
4
  export declare const shouldDisableSpinner: () => boolean;
5
5
  export declare function isJsonMode(): boolean;
6
+ /**
7
+ * Pre-subcommand `ol --user <ref>` selector. cli-core's `parseGlobalArgs`
8
+ * already extracts it from argv; `applyUserSelector` strips the flag before
9
+ * Commander parses, so this reads the value off the warmed cache.
10
+ */
11
+ export declare function getRequestedUserRef(): string | undefined;
12
+ /**
13
+ * Guard a root `--user` against the two common footguns before it's stripped:
14
+ * a value-less flag (`--user`, `--user=`) and a forgotten value where the next
15
+ * token is actually a command (`ol --user document list`). Pure — pass the
16
+ * pre-strip argv and the set of registered command names. Silent when `--user`
17
+ * is absent, or when it appears *after* a command (a late flag is left for
18
+ * Commander to reject as an unknown option, matching what `stripUserFlag`
19
+ * leaves in argv).
20
+ */
21
+ export declare function validateRootUserFlag(argv: string[], knownCommands: ReadonlySet<string>): void;
22
+ /**
23
+ * Entrypoint wiring for the global `--user` selector, kept here so the
24
+ * validate → warm-cache → strip order is exercised by tests rather than living
25
+ * untested in `src/index.ts`. Validates the root flag, warms the global-args
26
+ * cache off the *original* argv (so the ref survives), then rewrites
27
+ * `process.argv` with the flag stripped for Commander. Throws `INVALID_USER_FLAG`
28
+ * on a malformed root flag.
29
+ */
30
+ export declare function applyUserSelector(knownCommands: ReadonlySet<string>): void;
@@ -1,4 +1,5 @@
1
- import { createAccessibleGate, createGlobalArgsStore, createSpinnerGate } from '@doist/cli-core';
1
+ import { createAccessibleGate, createGlobalArgsStore, createSpinnerGate, parseGlobalArgs, stripUserFlag, } from '@doist/cli-core';
2
+ import { CliError } from './errors.js';
2
3
  const store = createGlobalArgsStore();
3
4
  export const getGlobalArgs = store.get;
4
5
  export const resetGlobalArgs = store.reset;
@@ -14,4 +15,52 @@ export function isJsonMode() {
14
15
  const args = store.get();
15
16
  return args.json || args.ndjson;
16
17
  }
18
+ /**
19
+ * Pre-subcommand `ol --user <ref>` selector. cli-core's `parseGlobalArgs`
20
+ * already extracts it from argv; `applyUserSelector` strips the flag before
21
+ * Commander parses, so this reads the value off the warmed cache.
22
+ */
23
+ export function getRequestedUserRef() {
24
+ return store.get().user;
25
+ }
26
+ /**
27
+ * Guard a root `--user` against the two common footguns before it's stripped:
28
+ * a value-less flag (`--user`, `--user=`) and a forgotten value where the next
29
+ * token is actually a command (`ol --user document list`). Pure — pass the
30
+ * pre-strip argv and the set of registered command names. Silent when `--user`
31
+ * is absent, or when it appears *after* a command (a late flag is left for
32
+ * Commander to reject as an unknown option, matching what `stripUserFlag`
33
+ * leaves in argv).
34
+ */
35
+ export function validateRootUserFlag(argv, knownCommands) {
36
+ const userIdx = argv.findIndex((a) => a === '--user' || a.startsWith('--user='));
37
+ if (userIdx === -1)
38
+ return;
39
+ const firstCmdIdx = argv.findIndex((a) => knownCommands.has(a));
40
+ if (firstCmdIdx !== -1 && userIdx > firstCmdIdx)
41
+ return;
42
+ const ref = parseGlobalArgs(argv).user;
43
+ if (!ref) {
44
+ throw new CliError('INVALID_USER_FLAG', '--user requires a value: <id|name>.', [
45
+ 'Example: ol --user scott@example.com document list',
46
+ ]);
47
+ }
48
+ if (knownCommands.has(ref)) {
49
+ throw new CliError('INVALID_USER_FLAG', `--user requires a value: got "${ref}", which looks like a command — did you forget the value?`, [`Example: ol --user scott@example.com ${ref}`]);
50
+ }
51
+ }
52
+ /**
53
+ * Entrypoint wiring for the global `--user` selector, kept here so the
54
+ * validate → warm-cache → strip order is exercised by tests rather than living
55
+ * untested in `src/index.ts`. Validates the root flag, warms the global-args
56
+ * cache off the *original* argv (so the ref survives), then rewrites
57
+ * `process.argv` with the flag stripped for Commander. Throws `INVALID_USER_FLAG`
58
+ * on a malformed root flag.
59
+ */
60
+ export function applyUserSelector(knownCommands) {
61
+ const original = process.argv.slice(2);
62
+ validateRootUserFlag(original, knownCommands);
63
+ getRequestedUserRef();
64
+ process.argv = [process.argv[0], process.argv[1], ...stripUserFlag(original)];
65
+ }
17
66
  //# sourceMappingURL=global-args.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"global-args.js","sourceRoot":"","sources":["../../src/lib/global-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAEhG,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAA;AAErC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,GAAG,CAAA;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,KAAK,CAAA;AAE1C,MAAM,CAAC,MAAM,YA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AAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAA;AACjF,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { AuthAccount } from '@doist/cli-core/auth';
1
+ import type { AccountRef, AuthAccount } from '@doist/cli-core/auth';
2
2
  /**
3
3
  * Narrow account shape persisted by the keyring-backed token store.
4
4
  *
@@ -24,3 +24,9 @@ export declare function makeOutlineAccount(input: {
24
24
  oauthClientId?: string;
25
25
  teamName?: string;
26
26
  }): OutlineAccount;
27
+ /**
28
+ * Accepts the Outline user UUID or display name. Id matches are
29
+ * case-sensitive (UUIDs are canonical); label matches are case-insensitive
30
+ * so users can pass the name they see in `auth status`.
31
+ */
32
+ export declare function matchOutlineAccount(account: OutlineAccount, ref: AccountRef): boolean;
@@ -9,4 +9,14 @@ export function makeOutlineAccount(input) {
9
9
  teamName: input.teamName,
10
10
  };
11
11
  }
12
+ /**
13
+ * Accepts the Outline user UUID or display name. Id matches are
14
+ * case-sensitive (UUIDs are canonical); label matches are case-insensitive
15
+ * so users can pass the name they see in `auth status`.
16
+ */
17
+ export function matchOutlineAccount(account, ref) {
18
+ if (account.id === ref)
19
+ return true;
20
+ return account.label.toLowerCase() === ref.toLowerCase();
21
+ }
12
22
  //# sourceMappingURL=outline-account.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"outline-account.js","sourceRoot":"","sources":["../../src/lib/outline-account.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAA;AAE5D,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,KAMlC;IACG,OAAO;QACH,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,gBAAgB;QAC1C,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,EAAE;QACxC,QAAQ,EAAE,KAAK,CAAC,QAAQ;KAC3B,CAAA;AACL,CAAC"}
1
+ {"version":3,"file":"outline-account.js","sourceRoot":"","sources":["../../src/lib/outline-account.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAA;AAE5D,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,KAMlC;IACG,OAAO;QACH,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,gBAAgB;QAC1C,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,EAAE;QACxC,QAAQ,EAAE,KAAK,CAAC,QAAQ;KAC3B,CAAA;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuB,EAAE,GAAe;IACxE,IAAI,OAAO,CAAC,EAAE,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IACnC,OAAO,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,CAAA;AAC5D,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export declare const SKILL_NAME = "outline-cli";
2
2
  export declare const SKILL_DESCRIPTION = "Search and manage Outline wiki documents and collections via the ol CLI";
3
- export declare const SKILL_CONTENT = "# Outline CLI (ol)\n\nUse this skill when the user wants to interact with their Outline wiki/knowledge base.\n\n## Quick Reference\n\n- `ol search \"query\"` - Search documents\n- `ol doc list` - List documents\n- `ol doc get <id>` - Read a document\n- `ol doc open <id>` - Open document in browser\n- `ol doc create --title \"Title\" --collection <id>` - Create document\n- `ol col list` - List collections\n\n## Output Formats\n\nAll list commands support:\n- `--json` - JSON output (essential fields)\n- `--ndjson` - Newline-delimited JSON (streaming)\n- `--full` - Include all fields in JSON\n\n## Document References\n\nDocuments can be referenced by:\n- URL ID (the slug suffix after the last hyphen)\n- Full Outline URL (auto-extracted)\n- Document ID\n\n## Commands\n\n### Search\n```bash\nol search \"query\"\nol search \"query\" --limit 10\nol search \"query\" --collection <id>\nol search \"query\" --status published\nol search \"query\" --json\n```\n\n### Documents\n```bash\nol doc list --collection <id> --limit 25\nol doc list --sort title --direction ASC\nol doc get <id> # Rendered markdown\nol doc get <id> --raw # Raw markdown\nol doc get <id> --json\nol doc open <id> # Open in browser\nol doc create --title \"Title\" --collection <id> --text \"# Content\"\nol doc create --title \"Title\" --parent <ref> --text \"# Content\" # Nest under parent (collection inferred)\nol doc create --title \"Title\" --collection <id> --file ./doc.md\nol doc update <id> --title \"New Title\"\nol doc update <id> --file ./updated.md\nol doc move <id> --collection <target-id> # Move to collection root\nol doc move <id> --parent <ref> # Nest under parent (collection inferred)\nol doc archive <id>\nol doc unarchive <id>\nol doc delete <id> --confirm\n```\n\n### Collections\n```bash\nol col list\nol col get <id>\nol col create --name \"Name\" --description \"Desc\" --color \"#hex\"\nol col create --name \"Private\" --private\nol col update <id> --name \"New Name\"\nol col delete <id> --confirm\n```\n\n### Authentication\n```bash\nol auth login # OAuth login (opens browser); prompts for base URL + client ID if needed\nol auth login --base-url <url> # Specify Outline base URL for this login (saved for future use)\nol auth login --client-id <id> # Specify OAuth client ID for this login (saved for future use)\nol auth login --callback-port <port> # Override local OAuth callback port\nol auth login --read-only # Request read-only scopes (where supported by the Outline instance)\nol auth login --json | --ndjson # Machine-readable success envelope\nol auth status # Show current auth state\nol auth status --json | --ndjson # Machine-readable status envelope ({id, team, baseUrl, source})\nol auth logout # Clear saved credentials\nol auth logout --json | --ndjson # Machine-readable logout envelope ({ok: true}; --ndjson is silent)\n```\n\n### Update & Changelog\n```bash\nol update # Update CLI to latest version\nol update --check # Check for updates without installing, show channel\nol update --check --json # Check for updates as a JSON envelope\nol update --check --ndjson # Check for updates as NDJSON output\nol update --channel # Show current update channel\nol update switch --stable # Switch to stable release channel\nol update switch --pre-release # Switch to pre-release (next) channel\nol changelog # Show recent changelog entries\nol changelog -n 3 # Show last 3 versions\n```\n\n## Examples\n\n### Find and read a document\n```bash\nol search \"onboarding\" --json | jq '.[0].document.urlId'\nol doc get <urlId>\n```\n\n### Create a document from a file\n```bash\nol doc create --title \"Meeting Notes\" --collection <id> --file ./notes.md --publish\n```\n\n### List all collections and their documents\n```bash\nol col list --json\nol doc list --collection <id> --sort title --direction ASC\n```\n\n### Bulk export with ndjson\n```bash\nol doc list --ndjson --full | jq -r '.title'\n```\n";
3
+ export declare const SKILL_CONTENT = "# Outline CLI (ol)\n\nUse this skill when the user wants to interact with their Outline wiki/knowledge base.\n\n## Quick Reference\n\n- `ol search \"query\"` - Search documents\n- `ol doc list` - List documents\n- `ol doc get <id>` - Read a document\n- `ol doc open <id>` - Open document in browser\n- `ol doc create --title \"Title\" --collection <id>` - Create document\n- `ol col list` - List collections\n- `ol account` - List stored accounts; `ol account use <id|name>` sets the default\n\n## Output Formats\n\nAll list commands support:\n- `--json` - JSON output (essential fields)\n- `--ndjson` - Newline-delimited JSON (streaming)\n- `--full` - Include all fields in JSON\n\n## Global Options\n\n- `--user <id|name>` - Act as a specific stored account, matched by Outline user ID or display name. Each `ol auth login` stores an account (accounts can live on different Outline instances), and `--user` selects which one a command runs as; the token, base URL, and OAuth client ID all resolve from that account. Must be placed **before** the command, e.g. `ol --user scott@example.com doc list`. Omitted, commands use the default account. Overridden by `OUTLINE_API_TOKEN` when set.\n\n## Document References\n\nDocuments can be referenced by:\n- URL ID (the slug suffix after the last hyphen)\n- Full Outline URL (auto-extracted)\n- Document ID\n\n## Commands\n\n### Search\n```bash\nol search \"query\"\nol search \"query\" --limit 10\nol search \"query\" --collection <id>\nol search \"query\" --status published\nol search \"query\" --json\n```\n\n### Documents\n```bash\nol doc list --collection <id> --limit 25\nol doc list --sort title --direction ASC\nol doc get <id> # Rendered markdown\nol doc get <id> --raw # Raw markdown\nol doc get <id> --json\nol doc open <id> # Open in browser\nol doc create --title \"Title\" --collection <id> --text \"# Content\"\nol doc create --title \"Title\" --parent <ref> --text \"# Content\" # Nest under parent (collection inferred)\nol doc create --title \"Title\" --collection <id> --file ./doc.md\nol doc update <id> --title \"New Title\"\nol doc update <id> --file ./updated.md\nol doc move <id> --collection <target-id> # Move to collection root\nol doc move <id> --parent <ref> # Nest under parent (collection inferred)\nol doc archive <id>\nol doc unarchive <id>\nol doc delete <id> --confirm\n```\n\n### Collections\n```bash\nol col list\nol col get <id>\nol col create --name \"Name\" --description \"Desc\" --color \"#hex\"\nol col create --name \"Private\" --private\nol col update <id> --name \"New Name\"\nol col delete <id> --confirm\n```\n\n### Authentication\n```bash\nol auth login # OAuth login (opens browser); prompts for base URL + client ID if needed\nol auth login --base-url <url> # Specify Outline base URL for this login (saved for future use)\nol auth login --client-id <id> # Specify OAuth client ID for this login (saved for future use)\nol auth login --callback-port <port> # Override local OAuth callback port\nol auth login --read-only # Request read-only scopes (where supported by the Outline instance)\nol auth login --json | --ndjson # Machine-readable success envelope\nol auth status # Show current auth state\nol auth status --json | --ndjson # Machine-readable status envelope ({id, team, baseUrl, source})\nol auth logout # Clear saved credentials\nol auth logout --json | --ndjson # Machine-readable logout envelope ({ok: true}; --ndjson is silent)\n```\n\n### Accounts\n```bash\nol account # List stored accounts (default subcommand)\nol account list # List stored accounts, default marked\nol account list --json | --ndjson # Machine-readable list ({accounts, default}; --ndjson streams one per line)\nol account current # Show the active account (honours --user and OUTLINE_API_TOKEN)\nol account current --json | --ndjson # Discriminated by source: {source:\"stored\", account:{id, label, teamName, baseUrl, isDefault}} | {source:\"env\"} | {source:\"legacy\"}\nol account use <id|name> # Set the default account used when --user is omitted\nol account use <id|name> --json # Machine-readable envelope ({ok: true, default: <id>}; --ndjson is silent)\nol account remove <id|name> # Remove a stored account (clears keyring + config entry)\nol account remove <id|name> --json # Machine-readable envelope ({ok: true, removed: <id>}; --ndjson is silent)\n```\n\n### Update & Changelog\n```bash\nol update # Update CLI to latest version\nol update --check # Check for updates without installing, show channel\nol update --check --json # Check for updates as a JSON envelope\nol update --check --ndjson # Check for updates as NDJSON output\nol update --channel # Show current update channel\nol update switch --stable # Switch to stable release channel\nol update switch --pre-release # Switch to pre-release (next) channel\nol changelog # Show recent changelog entries\nol changelog -n 3 # Show last 3 versions\n```\n\n## Examples\n\n### Find and read a document\n```bash\nol search \"onboarding\" --json | jq '.[0].document.urlId'\nol doc get <urlId>\n```\n\n### Create a document from a file\n```bash\nol doc create --title \"Meeting Notes\" --collection <id> --file ./notes.md --publish\n```\n\n### List all collections and their documents\n```bash\nol col list --json\nol doc list --collection <id> --sort title --direction ASC\n```\n\n### Bulk export with ndjson\n```bash\nol doc list --ndjson --full | jq -r '.title'\n```\n";
@@ -12,6 +12,7 @@ Use this skill when the user wants to interact with their Outline wiki/knowledge
12
12
  - \`ol doc open <id>\` - Open document in browser
13
13
  - \`ol doc create --title "Title" --collection <id>\` - Create document
14
14
  - \`ol col list\` - List collections
15
+ - \`ol account\` - List stored accounts; \`ol account use <id|name>\` sets the default
15
16
 
16
17
  ## Output Formats
17
18
 
@@ -20,6 +21,10 @@ All list commands support:
20
21
  - \`--ndjson\` - Newline-delimited JSON (streaming)
21
22
  - \`--full\` - Include all fields in JSON
22
23
 
24
+ ## Global Options
25
+
26
+ - \`--user <id|name>\` - Act as a specific stored account, matched by Outline user ID or display name. Each \`ol auth login\` stores an account (accounts can live on different Outline instances), and \`--user\` selects which one a command runs as; the token, base URL, and OAuth client ID all resolve from that account. Must be placed **before** the command, e.g. \`ol --user scott@example.com doc list\`. Omitted, commands use the default account. Overridden by \`OUTLINE_API_TOKEN\` when set.
27
+
23
28
  ## Document References
24
29
 
25
30
  Documents can be referenced by:
@@ -82,6 +87,19 @@ ol auth logout # Clear saved credentials
82
87
  ol auth logout --json | --ndjson # Machine-readable logout envelope ({ok: true}; --ndjson is silent)
83
88
  \`\`\`
84
89
 
90
+ ### Accounts
91
+ \`\`\`bash
92
+ ol account # List stored accounts (default subcommand)
93
+ ol account list # List stored accounts, default marked
94
+ ol account list --json | --ndjson # Machine-readable list ({accounts, default}; --ndjson streams one per line)
95
+ ol account current # Show the active account (honours --user and OUTLINE_API_TOKEN)
96
+ ol account current --json | --ndjson # Discriminated by source: {source:"stored", account:{id, label, teamName, baseUrl, isDefault}} | {source:"env"} | {source:"legacy"}
97
+ ol account use <id|name> # Set the default account used when --user is omitted
98
+ ol account use <id|name> --json # Machine-readable envelope ({ok: true, default: <id>}; --ndjson is silent)
99
+ ol account remove <id|name> # Remove a stored account (clears keyring + config entry)
100
+ ol account remove <id|name> --json # Machine-readable envelope ({ok: true, removed: <id>}; --ndjson is silent)
101
+ \`\`\`
102
+
85
103
  ### Update & Changelog
86
104
  \`\`\`bash
87
105
  ol update # Update CLI to latest version
@@ -1 +1 @@
1
- {"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAC1B,yEAAyE,CAAA;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsH5B,CAAA"}
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAC1B,yEAAyE,CAAA;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwI5B,CAAA"}