popost 4.6.10 → 4.6.12

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 (98) hide show
  1. package/README.md +2 -0
  2. package/SKILL.md +5 -3
  3. package/assets/canvas/assets/{dist-C40jmU-w.js → dist-DAI3U0Jz.js} +1 -1
  4. package/assets/canvas/assets/{es-aF1SvUMY.js → es-3zEBH4X5.js} +1 -1
  5. package/assets/canvas/assets/index-Ce4sDSi9.css +1 -0
  6. package/assets/canvas/assets/{index-CxUXSxcb.js → index-Dc4qgNYJ.js} +4 -4
  7. package/assets/canvas/assets/{jszip.min-Bf2BQwaC.js → jszip.min-BwYI3Gs3.js} +1 -1
  8. package/assets/canvas/build-info.json +6 -6
  9. package/assets/canvas/index.html +2 -2
  10. package/dist/cli.js +18401 -14673
  11. package/dist/index.js +19448 -15784
  12. package/dist/types/cloud/account.d.ts +14 -0
  13. package/dist/types/cloud/deliver.d.ts +29 -0
  14. package/dist/types/cloud/entitlement.d.ts +55 -0
  15. package/dist/types/cloud/paid-gate.d.ts +159 -0
  16. package/dist/types/cloud/service.d.ts +68 -23
  17. package/dist/types/commands/update.d.ts +2 -0
  18. package/dist/types/device-login.d.ts +35 -0
  19. package/dist/types/editor/canvas-state.d.ts +1 -1
  20. package/dist/types/editor/handoff.d.ts +10 -3
  21. package/dist/types/editor/http-types.d.ts +4 -1
  22. package/dist/types/editor/routes-cloud.d.ts +4 -3
  23. package/dist/types/install/record.d.ts +15 -0
  24. package/dist/types/providers/api-errors.d.ts +2 -0
  25. package/dist/types/providers/api.d.ts +1 -1
  26. package/dist/types/providers/link-resolve.d.ts +29 -0
  27. package/dist/types/providers/link.d.ts +2 -0
  28. package/dist/types/runtime.d.ts +38 -0
  29. package/dist/types/update/auto.d.ts +14 -0
  30. package/dist/types/update/check.d.ts +47 -0
  31. package/dist/types/update/install-kind.d.ts +27 -0
  32. package/dist/types/update/npm.d.ts +8 -0
  33. package/dist/types/update/perform.d.ts +64 -0
  34. package/dist/types/update/report.d.ts +7 -0
  35. package/dist/types/update/semver.d.ts +17 -0
  36. package/dist/types/update/session.d.ts +19 -0
  37. package/dist/types/update/state.d.ts +91 -0
  38. package/dist/types/update/verify.d.ts +33 -0
  39. package/dist/types/version.d.ts +1 -1
  40. package/dist/types/video/cache/frames.d.ts +85 -0
  41. package/dist/types/video/cache/holds.d.ts +35 -0
  42. package/dist/types/video/cache/project.d.ts +57 -0
  43. package/dist/types/video/commands/clean.d.ts +9 -0
  44. package/dist/types/video/commands/inputs.d.ts +2 -0
  45. package/dist/types/video/commands/materials.d.ts +6 -0
  46. package/dist/types/video/commands/product.d.ts +15 -0
  47. package/dist/types/video/commands/shared.d.ts +0 -5
  48. package/dist/types/video/compile/footage.d.ts +24 -7
  49. package/dist/types/video/compile/index.d.ts +3 -0
  50. package/dist/types/video/generate/cloud-image.d.ts +3 -1
  51. package/dist/types/video/generate/cloud.d.ts +5 -0
  52. package/dist/types/video/generate/dialogue.d.ts +2 -10
  53. package/dist/types/video/generate/index.d.ts +23 -2
  54. package/dist/types/video/inputs/collect.d.ts +104 -0
  55. package/dist/types/video/inputs/record.d.ts +106 -0
  56. package/dist/types/video/inputs/sheet.d.ts +8 -0
  57. package/dist/types/video/inputs/summary.d.ts +72 -0
  58. package/dist/types/video/preview/cloud.d.ts +20 -1
  59. package/dist/types/video/preview/edit/routes.d.ts +17 -11
  60. package/dist/types/video/preview/export-settings.d.ts +1 -2
  61. package/dist/types/video/preview/project.d.ts +3 -0
  62. package/dist/types/video/preview/shell/dom.d.ts +2 -0
  63. package/dist/types/video/preview/shell/studio/cloud.d.ts +6 -1
  64. package/dist/types/video/preview/shell/studio/compare.d.ts +16 -0
  65. package/dist/types/video/preview/shell/studio/copy.d.ts +24 -3
  66. package/dist/types/video/preview/shell/studio/paid.d.ts +23 -0
  67. package/dist/types/video/preview/shell/studio/style.d.ts +2 -2
  68. package/dist/types/video/preview/shell/studio/workspace.d.ts +2 -0
  69. package/dist/types/video/preview/shell-bundle.d.ts +1 -1
  70. package/dist/types/video/product/requests.d.ts +74 -0
  71. package/dist/types/video/product/review.d.ts +74 -0
  72. package/dist/types/video/product/sheet.d.ts +122 -0
  73. package/dist/types/video/project/schema.d.ts +21 -21
  74. package/dist/types/video/prompt-lang.d.ts +16 -0
  75. package/dist/types/video/render/index.d.ts +2 -0
  76. package/dist/types/video/render/session.d.ts +4 -0
  77. package/dist/types/video/replication/contract.d.ts +29 -29
  78. package/dist/types/video/replication/production.d.ts +5 -5
  79. package/dist/types/video/replication/schema.d.ts +2 -2
  80. package/dist/types/video/replication/speech-observed.d.ts +6 -6
  81. package/dist/types/video/sound/modes.d.ts +0 -8
  82. package/package.json +1 -1
  83. package/references/host-editor.md +21 -6
  84. package/references/image-workflow.md +5 -5
  85. package/references/onboarding.md +22 -1
  86. package/references/post-bundle.md +10 -8
  87. package/references/video-editing.md +19 -7
  88. package/references/video-performers.md +4 -2
  89. package/references/video-product.md +196 -0
  90. package/references/video-replication.md +1 -1
  91. package/references/video-step-1-read.md +16 -6
  92. package/references/video-step-3-content.md +15 -7
  93. package/references/video-step-6-voice.md +10 -0
  94. package/references/video-step-7-deliver.md +36 -1
  95. package/references/video-tools.md +61 -7
  96. package/references/video.md +26 -0
  97. package/assets/canvas/assets/index-C5rz5H21.css +0 -1
  98. package/dist/types/cloud/auth-flow.d.ts +0 -30
@@ -0,0 +1,14 @@
1
+ import type { PopostClient } from '../providers/api';
2
+ import { cloudSyncOffText } from '../providers/api-errors';
3
+ /** The platform's refusal of `POST /projects/sync` while the account's switch is off; also the code of a local refusal. */
4
+ export declare const CLOUD_SYNC_OFF = "CLOUD_SYNC_OFF";
5
+ export interface CloudAccount {
6
+ readonly userId?: string;
7
+ /** False only when the platform says so. */
8
+ readonly cloudSync: boolean;
9
+ }
10
+ export declare const parseAccount: (me: unknown) => CloudAccount;
11
+ export declare const readAccount: (client: PopostClient, timeoutSec?: number) => Promise<CloudAccount>;
12
+ /** Where the user turns cloud sync on or off: the Connections & API Key page of the site this client talks to. */
13
+ export declare const manageUrlOf: (client: PopostClient) => string;
14
+ export { cloudSyncOffText };
@@ -0,0 +1,29 @@
1
+ import type { Runtime } from '../runtime';
2
+ import type { CloudLang, CloudService } from './service';
3
+ export type CloudDelivery = {
4
+ readonly state: 'saved';
5
+ readonly webUrl: string;
6
+ } | {
7
+ readonly state: 'failed';
8
+ readonly error: {
9
+ readonly code: string;
10
+ readonly message: string;
11
+ };
12
+ }
13
+ /** The account's switch is off: nothing was sent. `manageUrl` is the page on popost.ai where the user turns it on. */
14
+ | {
15
+ readonly state: 'paused';
16
+ readonly manageUrl?: string;
17
+ };
18
+ /**
19
+ * Whether a command syncs its finished output itself. Not under a host that shows projects in its own editor (the
20
+ * popost.ai workbench runs the Skill for its own Agent): the host keeps the project, and the credential it passes is its
21
+ * own, so a sync from here would at best add a second copy of the project to the account and at worst report a failure
22
+ * that is none. `present` leaves such a host alone in the same way.
23
+ */
24
+ export declare const commandSyncs: (rt: Runtime) => boolean;
25
+ /**
26
+ * The service's project, synced once. `undefined` when no account is connected or cloud sync is disabled for the command:
27
+ * nothing was sent and the JSON says nothing about the cloud.
28
+ */
29
+ export declare const deliverToCloud: (service: CloudService, lang?: CloudLang) => Promise<CloudDelivery | undefined>;
@@ -0,0 +1,55 @@
1
+ import type { Runtime } from '../runtime';
2
+ import type { CloudLang, CloudMode } from './service';
3
+ export type EntitlementState = 'unknown' | 'free' | 'paid';
4
+ export interface Entitlement {
5
+ readonly ok: true;
6
+ readonly state: EntitlementState;
7
+ /** An account is connected (an API key or a device connection), whatever its plan. */
8
+ readonly connected: boolean;
9
+ /** `state === 'paid'`; the field older editors read. */
10
+ readonly premium: boolean;
11
+ /** The plan was read from the platform (false while unknown); the field older Studio shells read. */
12
+ readonly verified: boolean;
13
+ readonly tier?: string;
14
+ /** The pricing page of the configured site, in the editor's language. */
15
+ readonly pricingUrl: string;
16
+ /** This process can open a page in the system browser (`POST /api/open-pricing`, `start` with `open`). */
17
+ readonly canOpenExternal: boolean;
18
+ /** Not connected: the account can be connected from the editor (cloud save is not off). */
19
+ readonly canConnect: boolean;
20
+ }
21
+ export interface Opened {
22
+ /** The system browser was launched; false leaves the editor to show the address. */
23
+ readonly opened: boolean;
24
+ readonly url: string;
25
+ }
26
+ /** How long a plan read from the platform is trusted without being asked for. */
27
+ export declare const ENTITLEMENT_TTL_MS = 180000;
28
+ /** A fresh read is not repeated sooner than this (several windows and a poll may ask at once). */
29
+ export declare const ENTITLEMENT_FRESH_MS = 2000;
30
+ export declare const entitlementLang: (value: unknown) => CloudLang;
31
+ /** The plan of a `GET /me` answer: its tier, and whether it includes the paid export options. */
32
+ export declare const planOf: (me: unknown) => {
33
+ tier?: string;
34
+ premium: boolean;
35
+ } | null;
36
+ export declare class ExportEntitlement {
37
+ private readonly rt;
38
+ /** The cloud mode of the service: connecting from the editor needs cloud save to be on. */
39
+ private readonly cloudMode;
40
+ private known;
41
+ private reading;
42
+ constructor(rt: Runtime,
43
+ /** The cloud mode of the service: connecting from the editor needs cloud save to be on. */
44
+ cloudMode?: () => CloudMode);
45
+ private get runtime();
46
+ private client;
47
+ pricingUrl(lang: CloudLang): string;
48
+ private read;
49
+ /** The current entitlement; `fresh` asks the platform again instead of trusting an answer of the last minutes. */
50
+ status(lang: CloudLang, fresh?: boolean): Promise<Entitlement>;
51
+ /** Open the pricing page in the system browser. The address is this service's own; the caller chooses the language only. */
52
+ openPricing(lang: CloudLang): Promise<Opened>;
53
+ }
54
+ /** Launch the system browser when the runtime can; never throws. */
55
+ export declare const openInSystemBrowser: (rt: Runtime, url: string) => Promise<boolean>;
@@ -0,0 +1,159 @@
1
+ /**
2
+ * The paid export options of an editor, as one small state machine with no DOM, no framework and no import: the image
3
+ * editor's export panel (`packages/canvas-editor/src/ui/PaidPrompt.tsx`, which imports this file into its bundle) and the
4
+ * video Studio's export dialog (`video/preview/shell/studio/paid.ts`) both drive it, so a paid option behaves the same in
5
+ * both. The service side of it is `entitlement.ts`.
6
+ *
7
+ * The account's access is `paid`, `free` or `unknown` (no account connected, or the plan could not be read). A click on
8
+ * a paid option goes through `request`:
9
+ * - paid: the option is applied at once.
10
+ * - free: the option is remembered and a prompt leads to the pricing page. A local editor asks its own service to open
11
+ * the page in the system browser (the editor may be shown in an agent's side panel, where the user is not signed in);
12
+ * when that cannot be done the address is shown to copy. A hosted editor links to the page in a new tab.
13
+ * - unknown: the prompt connects the account first (the device authorization of the cloud button); when the connection
14
+ * is approved the flow goes on by itself to "paid" or "free".
15
+ * While an option is remembered the access is read again every few seconds and whenever the window gets the focus
16
+ * back, so the option is applied without a reload once the user has paid.
17
+ */
18
+ export type PaidState = 'unknown' | 'free' | 'paid';
19
+ export interface PaidAccess {
20
+ readonly state: PaidState;
21
+ readonly connected: boolean;
22
+ readonly pricingUrl: string;
23
+ /** The local service can open a page in the system browser. */
24
+ readonly canOpenExternal: boolean;
25
+ /** No account yet, and one can be connected from this editor. */
26
+ readonly canConnect: boolean;
27
+ }
28
+ export interface PaidConnect {
29
+ /** The approval page with the code filled in. */
30
+ readonly authorizeUrl: string;
31
+ /** The code that page shows, for the user to compare. */
32
+ readonly userCode: string;
33
+ /** The service opened the page in the system browser; false shows the address instead. */
34
+ readonly opened: boolean;
35
+ }
36
+ /** What an editor gives the machine. A hosted editor has `access` only. */
37
+ export interface PaidGateApi {
38
+ /** `fresh`: ask the platform again instead of trusting a recent answer. */
39
+ access(fresh: boolean): Promise<PaidAccess>;
40
+ /** Start connecting the account, or learn that it is connected already. */
41
+ connect?(): Promise<{
42
+ readonly connected: true;
43
+ } | ({
44
+ readonly connected: false;
45
+ } & PaidConnect)>;
46
+ /** A connection that was started (here, or by the cloud button): still waiting, or how it failed. */
47
+ connection?(): Promise<{
48
+ readonly waiting: boolean;
49
+ readonly connect?: Omit<PaidConnect, 'opened'>;
50
+ readonly error?: string;
51
+ }>;
52
+ /** Ask the local service to open the pricing page in the system browser. */
53
+ openPricing?(): Promise<{
54
+ readonly opened: boolean;
55
+ readonly url: string;
56
+ }>;
57
+ }
58
+ export type PaidPrompt<Id> = {
59
+ readonly kind: 'checking';
60
+ readonly id: Id;
61
+ }
62
+ /** No account: `canConnect` false means it cannot be connected from here (the pricing page is still offered). */
63
+ | {
64
+ readonly kind: 'connect';
65
+ readonly id: Id;
66
+ readonly canConnect: boolean;
67
+ readonly busy: boolean;
68
+ readonly error?: string;
69
+ readonly pricingUrl: string;
70
+ } | ({
71
+ readonly kind: 'waiting';
72
+ readonly id: Id;
73
+ } & PaidConnect)
74
+ /**
75
+ * `via`: `service` asks the local service to open the page, `link` shows the address (the service cannot open a
76
+ * browser), `tab` is a plain link in a new tab (hosted). `opened`: undefined until asked, then whether a browser opened.
77
+ */
78
+ | {
79
+ readonly kind: 'pricing';
80
+ readonly id: Id;
81
+ readonly url: string;
82
+ readonly via: 'service' | 'link' | 'tab';
83
+ readonly busy: boolean;
84
+ readonly opened?: boolean;
85
+ }
86
+ /** Connected, but the plan could not be read. */
87
+ | {
88
+ readonly kind: 'retry';
89
+ readonly id: Id;
90
+ readonly busy: boolean;
91
+ };
92
+ export interface PaidSnapshot<Id> {
93
+ readonly access: PaidAccess | null;
94
+ readonly prompt: PaidPrompt<Id> | null;
95
+ }
96
+ export interface PaidGateOptions<Id> {
97
+ /** A remembered option was applied because the account turned out to be, or became, paid. */
98
+ readonly onUnlock?: (id: Id) => void;
99
+ readonly setTimer?: (run: () => void, ms: number) => unknown;
100
+ readonly clearTimer?: (timer: unknown) => void;
101
+ readonly now?: () => number;
102
+ }
103
+ /** Between two reads of the access while a prompt waits for the user to pay. */
104
+ export declare const PAID_POLL_MS = 5000;
105
+ /** Between two reads while the account connection waits for approval. */
106
+ export declare const PAID_CONNECT_POLL_MS = 2000;
107
+ /** After the window got the focus back (the user may have just paid): one more read this soon, then the usual pace. */
108
+ export declare const PAID_FOCUS_POLL_MS = 2500;
109
+ /** The reads stop this long after the user's last action on the prompt; the window's focus still triggers one. */
110
+ export declare const PAID_POLL_LIMIT_MS: number;
111
+ export declare class PaidGate<Id> {
112
+ private readonly api;
113
+ private readonly options;
114
+ private access;
115
+ private pending;
116
+ private connecting;
117
+ private error;
118
+ private busy;
119
+ private opened;
120
+ private timer;
121
+ private pollUntil;
122
+ private loading;
123
+ private disposed;
124
+ private current;
125
+ private readonly listeners;
126
+ private readonly setTimer;
127
+ private readonly clearTimer;
128
+ private readonly now;
129
+ constructor(api: PaidGateApi, options?: PaidGateOptions<Id>);
130
+ snapshot: () => PaidSnapshot<Id>;
131
+ subscribe: (listener: () => void) => (() => void);
132
+ /** Whether paid options are locked for now (also while the access is not known yet). */
133
+ locked: () => boolean;
134
+ private promptOf;
135
+ private emit;
136
+ private schedule;
137
+ /** The user acted on the prompt: the reads go on for another while. */
138
+ private touch;
139
+ private tick;
140
+ /** A connection being approved: learn that it was declined or expired, or (started elsewhere) show its code. */
141
+ private checkConnection;
142
+ /** Read the access. A failure keeps the last answer. Applies the remembered option when the account is paid. */
143
+ load(fresh?: boolean): Promise<void>;
144
+ private unlock;
145
+ /**
146
+ * A paid option was clicked. Paid: `apply` runs now and the answer is true. Otherwise the option is remembered, the
147
+ * prompt for it appears, and `apply` runs once the account is paid.
148
+ */
149
+ request(id: Id, apply: () => void): boolean;
150
+ /** The user chose something else: nothing is remembered. */
151
+ dismiss(): void;
152
+ /** Connect the account (the prompt's button while no account is connected). */
153
+ connect(): Promise<void>;
154
+ /** Open the pricing page through the local service (the prompt's button while the account is free). */
155
+ openPricing(): Promise<void>;
156
+ /** The window got the focus back, or the user asked to try again: read the access now. */
157
+ recheck(): Promise<void>;
158
+ dispose(): void;
159
+ }
@@ -1,9 +1,8 @@
1
1
  import type { DeckSession } from '../deck/types';
2
2
  import { PopostClient } from '../providers/api';
3
3
  import type { Runtime } from '../runtime';
4
- import { type RandomBytes } from './auth-flow';
5
4
  import type { CloudRecord } from './state';
6
- export type CloudMode = 'keyed' | 'anonymous' | 'off';
5
+ export type CloudMode = 'keyed' | 'paused' | 'anonymous' | 'off';
7
6
  export type CloudPhase = 'idle' | 'waiting' | 'uploading' | 'saved' | 'failed' | 'conflict';
8
7
  export type CloudLang = 'en' | 'zh';
9
8
  export interface CloudStatus {
@@ -14,11 +13,31 @@ export interface CloudStatus {
14
13
  readonly deckId?: string;
15
14
  readonly webUrl?: string;
16
15
  readonly syncedAt?: string;
16
+ /** Keyed and paused: the page on popost.ai where the account's cloud-sync switch is. */
17
+ readonly manageUrl?: string;
18
+ /** Waiting: the account connection the user has to approve on popost.ai. Never a credential. */
19
+ readonly connect?: CloudConnect;
20
+ /** This process can open the approval page in the system browser (`start` with `open`). */
21
+ readonly canOpenExternal?: boolean;
17
22
  readonly error?: {
18
23
  readonly code: string;
19
24
  readonly message: string;
20
25
  };
21
26
  }
27
+ export interface CloudConnect {
28
+ /** The approval page with the code filled in. */
29
+ readonly authorizeUrl: string;
30
+ /** The code the page shows, for the user to compare. */
31
+ readonly userCode: string;
32
+ readonly expiresAt: string;
33
+ }
34
+ /** What `start` answers: the connection to approve, or that an approval given earlier was found and the account is connected. */
35
+ export type CloudStart = ({
36
+ readonly connected: false; /** Asked to open the approval page: whether the system browser was launched. */
37
+ readonly opened?: boolean;
38
+ } & CloudConnect) | {
39
+ readonly connected: true;
40
+ };
22
41
  export interface CloudProjectAdapter {
23
42
  info(): Promise<{
24
43
  projectId: string;
@@ -36,17 +55,12 @@ export interface CloudOptions {
36
55
  /** Allow browser login only, even when the CLI has a key. */
37
56
  readonly loginOnly?: boolean;
38
57
  readonly session?: DeckSession;
39
- readonly randomBytes?: RandomBytes;
40
58
  /** Quiet time after the last local save before a keyed push. */
41
59
  readonly debounceMs?: number;
42
60
  }
43
61
  export declare const AUTO_PUSH_DELAY_MS = 3000;
44
- export type CallbackResult = {
45
- readonly ok: true;
46
- } | {
47
- readonly ok: false;
48
- readonly error: string;
49
- };
62
+ /** How long an answer of `GET /me` about the account's switch is trusted. */
63
+ export declare const SWITCH_TTL_MS = 30000;
50
64
  /** The mode a runtime is in: keyed when a popost key is configured, anonymous otherwise, off when disabled or unusable. */
51
65
  export declare const resolveCloudMode: (rt: Runtime, enabled?: boolean, loginOnly?: boolean) => CloudMode;
52
66
  export declare class CloudService {
@@ -57,45 +71,76 @@ export declare class CloudService {
57
71
  private known;
58
72
  private phase;
59
73
  private error;
60
- private readonly pending;
61
- private ticket;
74
+ private connecting;
75
+ /** An account was connected from this service: `--cloud login` no longer holds the service in anonymous mode. */
76
+ private connectedHere;
62
77
  private tail;
63
78
  private timer;
64
79
  private lastMode?;
65
80
  private get runtime();
66
81
  private lang;
82
+ /** The account's cloud-sync switch as last read; on until the platform says otherwise. */
83
+ private switchOn;
84
+ private switchAt;
85
+ private switchScope;
86
+ private switchRead;
67
87
  constructor(rt: Runtime, rootOf: () => string, options?: CloudOptions);
68
88
  private get root();
89
+ /** The mode by the credential alone: the account's switch is not looked at. */
90
+ private credentialMode;
91
+ /** Synchronous: `paused` comes from the switch as last read (`refreshSwitch` reads it). */
69
92
  mode: () => CloudMode;
93
+ private pausedError;
94
+ /**
95
+ * Read the account's switch when the last answer is older than 30 s or belongs to another credential. A failure keeps
96
+ * the last known value (on, when there is none) and is not asked again before the 30 s are over.
97
+ */
98
+ private refreshSwitch;
99
+ /** For a status poll: the switch when it answers quickly, the last known value otherwise (the read goes on). */
100
+ private switchSoon;
101
+ /** The platform refused a sync because the switch is off: the cache learns it without another request. */
102
+ private switchRefused;
70
103
  /** A different project is being served (`import-project`): nothing of the old one carries over. */
71
104
  private sync;
72
105
  private now;
73
- private liveTicket;
74
- private purgePending;
75
106
  status(): Promise<CloudStatus>;
76
- /** Begin the browser login on the service's `port`; returns the URL to open on popost.ai. */
77
- start(lang: CloudLang, port: number): Promise<{
78
- authorizeUrl: string;
79
- expiresAt: string;
80
- }>;
107
+ private connectOf;
108
+ private pause;
109
+ /** The account is connected: the service is keyed from here on, and the project is synced once. */
110
+ private connected;
81
111
  /**
82
- * The site sends the browser back here with a one-time code. The state must be one this service started, unexpired and
83
- * unused; the code must have the issued shape. Then the credential is formed and this project is pushed in the background.
112
+ * Anonymous mode: start the device authorization of `popost auth login`, or resume the request that command or another
113
+ * editor left in the same `.pending` file, and poll for the user's approval in the background. Returns the approval page
114
+ * and the code; when an earlier request turns out to be approved already, the account is connected at once. Refused
115
+ * (`CONNECT_UNAVAILABLE`) where no connection can be kept: a host without persistent user storage, or an explicit
116
+ * `POPOST_API_KEY`, which selects the account. With `open`, this process opens the approval page in the system browser
117
+ * (as `popost auth login` does), so an editor shown in an agent's side panel does not open it there; `opened` says whether
118
+ * a browser was launched.
84
119
  */
85
- callback(code: string | null, state: string | null): CallbackResult;
120
+ start(lang: CloudLang, open?: boolean): Promise<CloudStart>;
121
+ /** Poll at the site's interval until the request is approved, declined or expired, or another request replaced it. */
122
+ private awaitApproval;
86
123
  private enqueue;
87
124
  private clientFor;
88
125
  private runPush;
89
- /** Push now and wait for the outcome. Anonymous mode needs a live upload credential: without one the login must run first. */
126
+ /**
127
+ * Push now and wait for the outcome. Paused answers `ok: false` with `CLOUD_SYNC_OFF` and sends nothing. Anonymous mode
128
+ * answers `LOGIN_REQUIRED`: the account must be connected first (`start`).
129
+ */
90
130
  push(options: {
91
131
  force?: boolean;
92
132
  lang?: CloudLang;
93
133
  }): Promise<CloudStatus>;
134
+ /**
135
+ * For a command that has just finished the project's output: wait for the account's switch, then sync unless the web
136
+ * copy already has this very state. Answers like `push`.
137
+ */
138
+ deliver(lang?: CloudLang): Promise<CloudStatus>;
94
139
  /** After a local save (keyed only): push once the project has been quiet for a moment. Never throws, never waits. */
95
140
  scheduleAutoPush(): void;
96
141
  /** Once at service start (keyed only): bring the web copy up to date when the project changed since the last sync. */
97
142
  autoStart(): void;
98
143
  private autoPush;
99
- /** Stops the pending debounce (the service is closing). */
144
+ /** Stops the pending debounce and the wait for an approval (the service is closing); the request stays resumable. */
100
145
  dispose(): void;
101
146
  }
@@ -0,0 +1,2 @@
1
+ import type { CommandMain } from '../runtime';
2
+ export declare const main: CommandMain;
@@ -1,4 +1,5 @@
1
1
  import { UsageError } from './args';
2
+ import { type PendingLogin } from './device-pending';
2
3
  import { type CredentialsLocation } from './credentials';
3
4
  import type { Runtime } from './runtime';
4
5
  export interface DeviceGrant {
@@ -15,4 +16,38 @@ export declare class DeviceRequestError extends UsageError {
15
16
  }
16
17
  export declare const deviceApi: <T>(fetcher: Runtime["fetch"], baseUrl: string, route: string, payload: unknown) => Promise<T>;
17
18
  export declare const deviceTokenProvider: (grant: DeviceGrant, fetcher: Runtime["fetch"]) => (baseUrl: string) => Promise<string>;
19
+ /** Where one device connection is requested and kept: the site, the grant's file and the pending request beside it. */
20
+ export interface DeviceTarget {
21
+ readonly baseUrl: string;
22
+ /** The site's origin, e.g. `https://popost.ai`. */
23
+ readonly origin: string;
24
+ readonly profile: string;
25
+ /** The saved grant; `<file>.pending` is the request waiting for the user's approval. */
26
+ readonly file: string;
27
+ readonly pendingFile: string;
28
+ }
29
+ export type DevicePoll = 'approved' | 'pending' | 'denied' | 'expired';
30
+ /** A failure of the account service that may pass (a dropped connection, a timeout, 429, 5xx): ask again. */
31
+ export declare const isTransientDeviceError: (error: unknown) => boolean;
32
+ /**
33
+ * Whether and where this runtime can connect an account in the browser. Refuses a host without persistent user storage and
34
+ * an explicit `POPOST_API_KEY` (it selects the account); nothing is sent.
35
+ */
36
+ export declare const deviceTarget: (rt: Runtime, requestedBase?: string) => DeviceTarget;
37
+ /** The request saved by an earlier `auth login --no-wait` or editor button, or `null`; one for another site is refused. */
38
+ export declare const readDevicePending: (rt: Runtime, target: DeviceTarget) => Promise<PendingLogin | null>;
39
+ /** Resume `previous` while its code is valid; otherwise ask the site for a new code and save the request before anything shows it. */
40
+ export declare const startDevice: (rt: Runtime, target: DeviceTarget, previous: PendingLogin | null) => Promise<PendingLogin>;
41
+ /** Ask the site once what became of the request. A declined or expired request is forgotten. */
42
+ export declare const pollDevice: (rt: Runtime, target: DeviceTarget, pending: PendingLogin) => Promise<DevicePoll>;
43
+ /**
44
+ * The approved request becomes the saved connection: its first access token is fetched and checked against `GET /me`, then
45
+ * the grant is written and the pending request removed. Throws a non-retryable `DeviceRequestError` while the request is
46
+ * not approved. Neither the grant nor a token is returned or printed.
47
+ */
48
+ export declare const finishDevice: (rt: Runtime, target: DeviceTarget, pending: PendingLogin) => Promise<{
49
+ account: string;
50
+ }>;
51
+ /** The approval page of the site; with a code, the page opens on that request (the user still has to approve it). */
52
+ export declare const deviceVerificationUrl: (target: DeviceTarget, userCode?: string) => string;
18
53
  export declare const login: (rt: Runtime, requestedBase?: string, noOpen?: boolean, noWait?: boolean) => Promise<number>;
@@ -39,5 +39,5 @@ export declare const canvasNotes: (project: Project, operations?: readonly NoteO
39
39
  command: string;
40
40
  }>;
41
41
  /** The editor's `index.html` with this project's settings injected; the editor's own HTML/CSS/JS stays shared. */
42
- export declare const editorHtml: (project: Project, source: string, query?: string, cloud?: "keyed" | "anonymous" | "off") => string;
42
+ export declare const editorHtml: (project: Project, source: string, query?: string, cloud?: "keyed" | "paused" | "anonymous" | "off") => string;
43
43
  export {};
@@ -18,16 +18,23 @@ export interface CloudHandoff {
18
18
  readonly state: string;
19
19
  readonly webUrl?: string;
20
20
  readonly deckId?: string;
21
+ /** Paused (and a service with a connected account): the page on popost.ai where the account's cloud-sync switch is. */
22
+ readonly manageUrl?: string;
21
23
  readonly error?: {
22
24
  readonly code: string;
23
25
  readonly message: string;
24
26
  };
25
27
  }
26
28
  export declare const handoff: (rt: Runtime, project: Project, origin: string, host?: string, reused?: boolean, cloud?: CloudHandoff) => Record<string, unknown>;
27
- /** Reuse this project's running editor service or start a detached one, and describe how to open it. */
28
- export declare const presentLocal: (rt: Runtime, project: Project, host: string, port: number, cloud?: boolean, fallback?: CloudHandoff["error"]) => Promise<Record<string, unknown>>;
29
29
  /**
30
- * `present`: the host's own editor, the workbench tied to a configured key, or a local service.
30
+ * Reuse this project's running editor service or start a detached one, and describe how to open it. `pausedAt`: the
31
+ * account's cloud-sync switch was just read as off (the page that has it); the handoff says `paused` even when the
32
+ * service has not read it yet.
33
+ */
34
+ export declare const presentLocal: (rt: Runtime, project: Project, host: string, port: number, cloud?: boolean, fallback?: CloudHandoff["error"], pausedAt?: string) => Promise<Record<string, unknown>>;
35
+ /**
36
+ * `present`: the host's own editor, the workbench tied to a connected account, or a local service. An account whose
37
+ * cloud-sync switch is off gets the local editor with `cloud.mode: 'paused'`: nothing is synced.
31
38
  * A host's answer is the command's JSON as it is.
32
39
  */
33
40
  export declare const present: (rt: Runtime, project: Project, host: string, port: number, cloud?: boolean) => Promise<Record<string, unknown>>;
@@ -2,6 +2,7 @@
2
2
  * What the editor service exchanges with a transport: a plain request and a plain response, so every route is an
3
3
  * ordinary async function over `rt.fs` that a test can call without a socket (`server.ts` adapts Node's `http` to it).
4
4
  */
5
+ import type { ExportEntitlement } from '../cloud/entitlement';
5
6
  import type { CloudService } from '../cloud/service';
6
7
  import type { Project } from '../core/project';
7
8
  import type { Runtime } from '../runtime';
@@ -32,8 +33,10 @@ export interface ServiceState {
32
33
  root: string;
33
34
  /** `/_preview/<id>.html` -> sanitized document, kept in memory for a few minutes. */
34
35
  readonly previews: Map<string, Preview>;
35
- /** Cloud save: login flows, the upload credential, the button's phase and the background pushes. */
36
+ /** Cloud sync: the account connection being approved, the button's phase and the background pushes. */
36
37
  readonly cloud: CloudService;
38
+ /** What the connected account may export: the paid options of the export panel. */
39
+ readonly entitlement: ExportEntitlement;
37
40
  }
38
41
  export interface Ctx {
39
42
  readonly rt: Runtime;
@@ -1,7 +1,8 @@
1
1
  import { type ApiResponse, type Ctx } from './http-types';
2
- export declare const CLOUD_DONE_PATH = "/cloud-done.html";
3
2
  export declare const cloudStatus: (ctx: Ctx) => Promise<ApiResponse>;
4
3
  export declare const cloudStart: (ctx: Ctx) => Promise<ApiResponse>;
5
4
  export declare const cloudPush: (ctx: Ctx) => Promise<ApiResponse>;
6
- export declare const cloudCallback: (ctx: Ctx) => ApiResponse;
7
- export declare const cloudDone: () => ApiResponse;
5
+ /** `GET /api/export-options?lang=&fresh=1`: what the account may export, and where the pricing page is. */
6
+ export declare const exportOptions: (ctx: Ctx) => Promise<ApiResponse>;
7
+ /** `POST /api/open-pricing`: this process opens the pricing page of the configured site; the request chooses the language only. */
8
+ export declare const openPricing: (ctx: Ctx) => Promise<ApiResponse>;
@@ -0,0 +1,15 @@
1
+ import type { Runtime } from '../runtime';
2
+ export declare const INSTALLS_FILE = "installs.json";
3
+ export interface InstallRecord {
4
+ /** The skills directory; the Skill is in `<skillsDir>/popost`. */
5
+ readonly skillsDir: string;
6
+ /** The agent the copy was installed for (`custom` for a directory given with --dir, `shared` for the shared one). */
7
+ readonly agent: string;
8
+ readonly at: string;
9
+ }
10
+ /** True when `<skillsDir>/popost` holds a Skill. */
11
+ export declare const hasSkill: (rt: Runtime, skillsDir: string) => Promise<boolean>;
12
+ /** The recorded installs, as written; empty when there is no list or it cannot be read. */
13
+ export declare const readInstalls: (rt: Runtime) => Promise<InstallRecord[]>;
14
+ /** Adds the targets of an install to the list and drops the entries whose directory no longer holds the Skill. */
15
+ export declare const rememberInstalls: (rt: Runtime, added: readonly Pick<InstallRecord, "skillsDir" | "agent">[]) => Promise<void>;
@@ -3,5 +3,7 @@ export declare const DEFAULT_KEY_ENV = "POPOST_API_KEY";
3
3
  export declare const DEFAULT_KEY_PAGE = "https://popost.ai/account/api-keys";
4
4
  /** Python `"%d"` for whole numbers, `"%s"` otherwise; booleans and missing values print the fallback ("unknown"). */
5
5
  export declare const num: (value: unknown, fallback?: string) => string;
6
+ /** The account's cloud-sync switch is off (it lives on the Connections & API Key page, `manageUrl`). */
7
+ export declare const cloudSyncOffText: (manageUrl: string) => string;
6
8
  /** Only known fields are read; the server's own text is appended as it is, truncated. */
7
9
  export declare const describeError: (code: string | undefined, serverMessage?: unknown, details?: unknown, keyEnv?: string) => string;
@@ -43,7 +43,7 @@ export declare class PopostClient {
43
43
  readonly keyEnv: string;
44
44
  readonly timeoutSec: number;
45
45
  lastMeta: unknown;
46
- /** An explicit credential (the cloud-save upload ticket) that is used instead of the environment key. */
46
+ /** An explicit credential (the access token of a device connection being verified) used instead of the environment key. */
47
47
  private readonly bearer;
48
48
  constructor(rt: Runtime, options?: {
49
49
  baseUrl?: string | null;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Share links the CLI resolves on the user's own machine before a link is submitted to the platform.
3
+ *
4
+ * A share link carries no post id: it only redirects to the post. The platform follows such links from its servers, and
5
+ * some sites refuse those requests while a request from the user's machine gets through, so the CLI follows the
6
+ * redirects here first and submits the post link it ends at. Nothing is charged for this and nothing but the link
7
+ * itself is requested: https only, only hosts of the same site, at most MAX_HOPS hops of HOP_TIMEOUT_MS each, no
8
+ * cookies. A hop is a 3xx with a Location header, or an HTML page that stands for one (meta refresh,
9
+ * `location.replace("…")`, a link in `<noscript>`; at most the first HTML_HOP_MAX_BYTES of it are read); every other
10
+ * response body is discarded. When the walk fails for any reason the original link is submitted unchanged and the
11
+ * platform resolves it (or says why it cannot).
12
+ *
13
+ * The table mirrors the platform's own rules for the same links; short links the platform hands to its data source
14
+ * (Douyin, TikTok, Xiaohongshu, Instagram, Kuaishou, WeChat) are not resolved here.
15
+ */
16
+ import type { Runtime } from '../runtime';
17
+ export declare const MAX_HOPS = 5;
18
+ export declare const HOP_TIMEOUT_MS = 10000;
19
+ export declare const HTML_HOP_MAX_BYTES: number;
20
+ /**
21
+ * Where an HTML page sends its reader, or null: a meta refresh, then a `location.replace("…")` / `location = "…"` with
22
+ * a string literal, then a link inside `<noscript>`. Nothing else is read as a redirect.
23
+ */
24
+ export declare const htmlRedirectTarget: (html: string) => string | null;
25
+ /**
26
+ * The post link a share link leads to, or null when `link` is not a share link resolved locally or the walk did not
27
+ * reach a post (refused, failed, left the site, too many hops).
28
+ */
29
+ export declare const resolveShareLink: (rt: Runtime, link: string) => Promise<string | null>;
@@ -1,6 +1,8 @@
1
1
  import type { Runtime } from '../runtime';
2
2
  export declare const NOTE_MAX = 2000;
3
3
  export declare const TIMEOUT_MAX_SEC = 3600;
4
+ /** The default wait: as long as the platform lets a parse run (15 minutes) before it fails the task. */
5
+ export declare const TIMEOUT_DEFAULT_SEC = 900;
4
6
  export interface LinkOptions {
5
7
  readonly out?: string;
6
8
  readonly timeoutSec: number;