@celljs/ta-protocol 4.8.0 → 4.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 (93) hide show
  1. package/README.en.md +2 -2
  2. package/README.md +2 -2
  3. package/esm/common/access-protocol.d.ts +73 -0
  4. package/esm/common/access-protocol.js +9 -0
  5. package/esm/common/gateway-protocol.d.ts +81 -0
  6. package/esm/common/gateway-protocol.js +3 -0
  7. package/esm/common/index.d.ts +2 -0
  8. package/esm/common/index.js +2 -0
  9. package/esm/common/location.d.ts +5 -0
  10. package/esm/common/location.js +12 -0
  11. package/esm/common/package-protocol.d.ts +60 -1
  12. package/esm/common/package-protocol.js +12 -0
  13. package/esm/common/relay-protocol.d.ts +17 -0
  14. package/esm/common/settings-protocol.d.ts +2 -0
  15. package/esm/common/ta-extension-host.d.ts +9 -0
  16. package/esm/common/ta-extension-host.js +6 -0
  17. package/esm/common/ta-protocol.d.ts +110 -4
  18. package/esm/common/ta-protocol.js +33 -0
  19. package/esm/common/workspace-protocol.d.ts +12 -1
  20. package/esm/common/workspace-protocol.js +16 -0
  21. package/lib/common/access-protocol.d.ts +74 -0
  22. package/lib/common/access-protocol.js +12 -0
  23. package/lib/common/gateway-protocol.d.ts +82 -0
  24. package/lib/common/gateway-protocol.js +6 -0
  25. package/lib/common/index.d.ts +2 -0
  26. package/lib/common/index.js +2 -0
  27. package/lib/common/location.d.ts +5 -0
  28. package/lib/common/location.js +12 -0
  29. package/lib/common/package-protocol.d.ts +60 -1
  30. package/lib/common/package-protocol.js +13 -1
  31. package/lib/common/relay-protocol.d.ts +17 -0
  32. package/lib/common/settings-protocol.d.ts +2 -0
  33. package/lib/common/ta-extension-host.d.ts +9 -0
  34. package/lib/common/ta-extension-host.js +7 -1
  35. package/lib/common/ta-protocol.d.ts +110 -4
  36. package/lib/common/ta-protocol.js +34 -1
  37. package/lib/common/workspace-protocol.d.ts +12 -1
  38. package/lib/common/workspace-protocol.js +17 -1
  39. package/package.json +3 -2
  40. package/esm/common/auth-protocol.js.map +0 -1
  41. package/esm/common/index.js.map +0 -1
  42. package/esm/common/location.js.map +0 -1
  43. package/esm/common/package-protocol.js.map +0 -1
  44. package/esm/common/pi-types.js.map +0 -1
  45. package/esm/common/relay-protocol.js.map +0 -1
  46. package/esm/common/remote-protocol.js.map +0 -1
  47. package/esm/common/settings-protocol.js.map +0 -1
  48. package/esm/common/ta-extension-host.js.map +0 -1
  49. package/esm/common/ta-protocol.js.map +0 -1
  50. package/esm/common/workspace-protocol.js.map +0 -1
  51. package/lib/common/auth-protocol.d.ts.map +0 -1
  52. package/lib/common/auth-protocol.js.map +0 -1
  53. package/lib/common/index.d.ts.map +0 -1
  54. package/lib/common/index.js.map +0 -1
  55. package/lib/common/location.d.ts.map +0 -1
  56. package/lib/common/location.js.map +0 -1
  57. package/lib/common/location.spec.d.ts +0 -2
  58. package/lib/common/location.spec.d.ts.map +0 -1
  59. package/lib/common/location.spec.js +0 -58
  60. package/lib/common/location.spec.js.map +0 -1
  61. package/lib/common/package-protocol.d.ts.map +0 -1
  62. package/lib/common/package-protocol.js.map +0 -1
  63. package/lib/common/pi-types.d.ts.map +0 -1
  64. package/lib/common/pi-types.js.map +0 -1
  65. package/lib/common/relay-protocol.d.ts.map +0 -1
  66. package/lib/common/relay-protocol.js.map +0 -1
  67. package/lib/common/remote-protocol.d.ts.map +0 -1
  68. package/lib/common/remote-protocol.js.map +0 -1
  69. package/lib/common/settings-protocol.d.ts.map +0 -1
  70. package/lib/common/settings-protocol.js.map +0 -1
  71. package/lib/common/ta-extension-host.d.ts.map +0 -1
  72. package/lib/common/ta-extension-host.js.map +0 -1
  73. package/lib/common/ta-protocol.d.ts.map +0 -1
  74. package/lib/common/ta-protocol.js.map +0 -1
  75. package/lib/common/ta-protocol.spec.d.ts +0 -2
  76. package/lib/common/ta-protocol.spec.d.ts.map +0 -1
  77. package/lib/common/ta-protocol.spec.js +0 -41
  78. package/lib/common/ta-protocol.spec.js.map +0 -1
  79. package/lib/common/workspace-protocol.d.ts.map +0 -1
  80. package/lib/common/workspace-protocol.js.map +0 -1
  81. package/src/common/auth-protocol.ts +0 -56
  82. package/src/common/index.ts +0 -10
  83. package/src/common/location.spec.ts +0 -62
  84. package/src/common/location.ts +0 -177
  85. package/src/common/package-protocol.ts +0 -99
  86. package/src/common/pi-types.ts +0 -11
  87. package/src/common/relay-protocol.ts +0 -28
  88. package/src/common/remote-protocol.ts +0 -76
  89. package/src/common/settings-protocol.ts +0 -73
  90. package/src/common/ta-extension-host.ts +0 -97
  91. package/src/common/ta-protocol.spec.ts +0 -48
  92. package/src/common/ta-protocol.ts +0 -352
  93. package/src/common/workspace-protocol.ts +0 -120
@@ -17,9 +17,23 @@ export const TaErrorCode = {
17
17
  COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED',
18
18
  /** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
19
19
  NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN',
20
+ /** Behind a gateway (`ta gateway`): the environment of the tenant did not start; TaGatewayServer changes or restarts it. */
21
+ ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED',
20
22
  /** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
21
23
  CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST',
22
24
  };
25
+ export var TaErrorUtil;
26
+ (function (TaErrorUtil) {
27
+ /** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
28
+ function code(error) {
29
+ var _a;
30
+ var _b;
31
+ const failure = error;
32
+ const code = (_b = failure === null || failure === void 0 ? void 0 : failure.code) !== null && _b !== void 0 ? _b : (_a = failure === null || failure === void 0 ? void 0 : failure.data) === null || _a === void 0 ? void 0 : _a.code;
33
+ return typeof code === 'string' ? code : undefined;
34
+ }
35
+ TaErrorUtil.code = code;
36
+ })(TaErrorUtil || (TaErrorUtil = {}));
23
37
  /** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
24
38
  export const TA_RPC_ERROR_CODE = -32050;
25
39
  /**
@@ -39,4 +53,23 @@ export var TaMessageContext;
39
53
  }
40
54
  TaMessageContext.strip = strip;
41
55
  })(TaMessageContext || (TaMessageContext = {}));
56
+ /** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
57
+ export var TaSkillUse;
58
+ (function (TaSkillUse) {
59
+ const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
60
+ function parse(message) {
61
+ var _a;
62
+ const match = BLOCK.exec(message);
63
+ if (!match) {
64
+ return undefined;
65
+ }
66
+ return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === void 0 ? void 0 : _a.trim()) || undefined };
67
+ }
68
+ TaSkillUse.parse = parse;
69
+ /** What the user typed: `/skill:name` and what follows. */
70
+ function command(use) {
71
+ return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
72
+ }
73
+ TaSkillUse.command = command;
74
+ })(TaSkillUse || (TaSkillUse = {}));
42
75
  //# sourceMappingURL=ta-protocol.js.map
@@ -12,6 +12,17 @@ export interface TaDirEntry {
12
12
  kind: 'file' | 'directory';
13
13
  size?: number;
14
14
  }
15
+ /**
16
+ * What a list of files hides unless asked, by name at any depth, as VS Code's default `files.exclude`:
17
+ * the data of version control and what systems leave in folders.
18
+ */
19
+ export declare namespace TaExcludedFiles {
20
+ const NAMES: readonly string[];
21
+ function has(name: string): boolean;
22
+ function filter<T extends {
23
+ name: string;
24
+ }>(entries: T[]): T[];
25
+ }
15
26
  export interface TaFileContent {
16
27
  path: string;
17
28
  size: number;
@@ -57,7 +68,7 @@ export interface TaCommandOutput {
57
68
  * the work runs in the execution environment of `cwd`, as the tools of a session do.
58
69
  */
59
70
  export interface TaWorkspaceServer {
60
- /** Directories first, then by name; `.git` is left out. */
71
+ /** Directories first, then by name; every entry, `.git` too: a client hides what it does not show ({@link TaExcludedFiles}). */
61
72
  listDirectory(path: string, cwd?: string): Promise<TaDirEntry[]>;
62
73
  readFile(path: string, cwd?: string): Promise<TaFileContent>;
63
74
  /** Writes the text of a file; its directory must be there. */
@@ -4,6 +4,22 @@ export const TaWorkspaceServer = Symbol('TaWorkspaceServer');
4
4
  export const TA_WORKSPACE_SERVICE = 'TaWorkspaceServer';
5
5
  export const TaTerminalServer = Symbol('TaTerminalServer');
6
6
  export const TA_TERMINAL_SERVICE = 'TaTerminalServer';
7
+ /**
8
+ * What a list of files hides unless asked, by name at any depth, as VS Code's default `files.exclude`:
9
+ * the data of version control and what systems leave in folders.
10
+ */
11
+ export var TaExcludedFiles;
12
+ (function (TaExcludedFiles) {
13
+ TaExcludedFiles.NAMES = ['.git', '.svn', '.hg', '.DS_Store', 'Thumbs.db'];
14
+ function has(name) {
15
+ return TaExcludedFiles.NAMES.includes(name);
16
+ }
17
+ TaExcludedFiles.has = has;
18
+ function filter(entries) {
19
+ return entries.filter(entry => !has(entry.name));
20
+ }
21
+ TaExcludedFiles.filter = filter;
22
+ })(TaExcludedFiles || (TaExcludedFiles = {}));
7
23
  /**
8
24
  * The most bytes of a part of {@link TaWorkspaceServer.uploadFile}: a larger file goes in parts of this size,
9
25
  * well within what a message of the WebSocket may hold once in base64.
@@ -0,0 +1,74 @@
1
+ export declare const TaAccessServer: unique symbol;
2
+ export declare const TA_ACCESS_SERVICE = "TaAccessServer";
3
+ /**
4
+ * Where a browser signs in with an account: `GET` it for the ways this ta serve offers ({@link TaSignInWays}),
5
+ * `GET <path>/<provider>` to go to the provider, which comes back to `<path>/<provider>/callback`. These are
6
+ * pages the browser goes to, not calls: they need no token, and give one.
7
+ */
8
+ export declare const TA_SIGN_IN_PATH = "/sign-in";
9
+ /** What a sign-in that did not let the browser in says in the fragment of the page it comes back to. */
10
+ export type TaSignInOutcome = 'denied' | 'failed';
11
+ /** A way to sign in: `github`, `google`, `wechat`, `oidc` (a provider of the operator's). */
12
+ export interface TaSignInProvider {
13
+ id: string;
14
+ /** What the button says: GitHub, Google, WeChat, or the name of the operator's provider. */
15
+ name: string;
16
+ }
17
+ /** The answer of `GET` {@link TA_SIGN_IN_PATH}. */
18
+ export interface TaSignInWays {
19
+ providers: TaSignInProvider[];
20
+ }
21
+ /**
22
+ * An account let in: `github:<login>`, `google:<email>`, `wechat:<id>`, `oidc:<email>`; `google:*@<domain>`
23
+ * lets in every address of the domain. Those of `TA_ALLOWED_USERS` (`env`) are not removed here.
24
+ */
25
+ export interface TaAccessAccount {
26
+ id: string;
27
+ name?: string;
28
+ avatar?: string;
29
+ source: 'env' | 'added';
30
+ addedAt?: number;
31
+ }
32
+ /** Someone who signed in and is not let in yet: one tap lets them in. */
33
+ export interface TaAccessRequest {
34
+ id: string;
35
+ name?: string;
36
+ avatar?: string;
37
+ at: number;
38
+ }
39
+ /** A browser signed in with an account; it stays signed in until it is signed out or its account removed. */
40
+ export interface TaAccessSignIn {
41
+ id: string;
42
+ account: string;
43
+ name?: string;
44
+ createdAt: number;
45
+ lastUsedAt: number;
46
+ /** The user agent of the browser it signed in from. */
47
+ device?: string;
48
+ /** The connection that asks. */
49
+ current: boolean;
50
+ }
51
+ export interface TaAccessInfo {
52
+ providers: TaSignInProvider[];
53
+ /** May let accounts in and out: anyone in with ta serve, administrators behind a gateway. */
54
+ canManage?: boolean;
55
+ accounts: TaAccessAccount[];
56
+ requests: TaAccessRequest[];
57
+ signIns: TaAccessSignIn[];
58
+ }
59
+ /** Who may reach this ta serve with an account, for whoever is in (with the token, or an account let in). */
60
+ export interface TaAccessServer {
61
+ getAccess(): Promise<TaAccessInfo>;
62
+ /**
63
+ * Where the browser goes to sign in with `provider` and let that account in at once: the owner, in with
64
+ * the token, adds an account of their own. The link works once, for a few minutes.
65
+ */
66
+ bindUrl(provider: string): Promise<string>;
67
+ /** Lets the account in (a request, or one typed); its request goes. */
68
+ allow(account: string, name?: string): Promise<void>;
69
+ dismiss(account: string): Promise<void>;
70
+ /** An account added here is no longer let in; its browsers are signed out at once. */
71
+ disallow(account: string): Promise<void>;
72
+ signOut(signInId: string): Promise<void>;
73
+ }
74
+ //# sourceMappingURL=access-protocol.d.ts.map
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TA_SIGN_IN_PATH = exports.TA_ACCESS_SERVICE = exports.TaAccessServer = void 0;
4
+ exports.TaAccessServer = Symbol('TaAccessServer');
5
+ exports.TA_ACCESS_SERVICE = 'TaAccessServer';
6
+ /**
7
+ * Where a browser signs in with an account: `GET` it for the ways this ta serve offers ({@link TaSignInWays}),
8
+ * `GET <path>/<provider>` to go to the provider, which comes back to `<path>/<provider>/callback`. These are
9
+ * pages the browser goes to, not calls: they need no token, and give one.
10
+ */
11
+ exports.TA_SIGN_IN_PATH = '/sign-in';
12
+ //# sourceMappingURL=access-protocol.js.map
@@ -0,0 +1,82 @@
1
+ export declare const TaGatewayServer: unique symbol;
2
+ export declare const TA_GATEWAY_SERVICE = "TaGatewayServer";
3
+ /**
4
+ * Where the Ta of a tenant runs: a sandbox of the gateway's provider (a container, a machine), or a Ta service
5
+ * of the user's own. `starting` until it answers; `failed` with `error` when it did not start.
6
+ */
7
+ export type TaEnvironmentStatus = 'starting' | 'running' | 'stopped' | 'failed';
8
+ /** A provider of sandboxes of the gateway that a user may run their Ta in (`sandboxes.json`). */
9
+ export interface TaEnvironmentOption {
10
+ id: string;
11
+ name: string;
12
+ /** `docker`, `command`, `local`, or that of a module. */
13
+ type: string;
14
+ }
15
+ /**
16
+ * The environment a user picks: one of the gateway's providers, or a Ta service of their own, reached at
17
+ * `url` (http or https, as `ta serve` there serves) with its access token, as a model of one's own is an
18
+ * endpoint and a key in pi's models.json.
19
+ */
20
+ export type TaEnvironmentChoice = {
21
+ provider: string;
22
+ } | {
23
+ type: 'ta';
24
+ url: string;
25
+ token: string;
26
+ name?: string;
27
+ };
28
+ export interface TaEnvironmentInfo {
29
+ /** The provider of the gateway, or `own` for a Ta service of the user's. */
30
+ provider: string;
31
+ name: string;
32
+ status: TaEnvironmentStatus;
33
+ error?: string;
34
+ /** That of a Ta service of the user's; never its token. */
35
+ url?: string;
36
+ }
37
+ /** A tenant, as an administrator sees it: one per account, its own sandbox. */
38
+ export interface TaGatewayTenant {
39
+ id: string;
40
+ account: string;
41
+ name?: string;
42
+ environment: TaEnvironmentInfo;
43
+ /** Browsers connected now. */
44
+ connections: number;
45
+ createdAt: number;
46
+ lastActiveAt?: number;
47
+ }
48
+ export interface TaGatewayInfo {
49
+ account: {
50
+ id: string;
51
+ name?: string;
52
+ avatar?: string;
53
+ };
54
+ tenant: string;
55
+ environment: TaEnvironmentInfo;
56
+ /** The providers of the gateway one may pick. */
57
+ options: TaEnvironmentOption[];
58
+ /** Whether a Ta service of one's own may be used (`ownEnvironments` of sandboxes.json). */
59
+ own: boolean;
60
+ /** May let accounts in (TA_GATEWAY_ADMINS) and see the tenants. */
61
+ admin: boolean;
62
+ }
63
+ /**
64
+ * `ta gateway`: each account that signs in is a tenant with a Ta of its own, in a sandbox of its own, which
65
+ * the gateway starts on its first connection and to which it forwards the connection. This service is the
66
+ * gateway's own, on the same WebSocket: a Ta service without a gateway does not have it.
67
+ */
68
+ export interface TaGatewayServer {
69
+ getGateway(): Promise<TaGatewayInfo>;
70
+ /**
71
+ * Runs the Ta of this tenant elsewhere from now on. Its sessions, model accounts and files are those of
72
+ * the environment: another starts without them. The connections of the tenant are closed, to connect again.
73
+ */
74
+ setEnvironment(choice: TaEnvironmentChoice): Promise<TaGatewayInfo>;
75
+ /** Starts the environment again: stopped first when it runs. */
76
+ restartEnvironment(): Promise<TaGatewayInfo>;
77
+ /** For administrators. */
78
+ listTenants(): Promise<TaGatewayTenant[]>;
79
+ /** For administrators: stops the sandbox of a tenant, which starts again when it connects. */
80
+ stopTenant(tenantId: string): Promise<void>;
81
+ }
82
+ //# sourceMappingURL=gateway-protocol.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TA_GATEWAY_SERVICE = exports.TaGatewayServer = void 0;
4
+ exports.TaGatewayServer = Symbol('TaGatewayServer');
5
+ exports.TA_GATEWAY_SERVICE = 'TaGatewayServer';
6
+ //# sourceMappingURL=gateway-protocol.js.map
@@ -1,4 +1,6 @@
1
+ export * from './access-protocol';
1
2
  export * from './auth-protocol';
3
+ export * from './gateway-protocol';
2
4
  export * from './location';
3
5
  export * from './package-protocol';
4
6
  export * from './pi-types';
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./access-protocol"), exports);
17
18
  __exportStar(require("./auth-protocol"), exports);
19
+ __exportStar(require("./gateway-protocol"), exports);
18
20
  __exportStar(require("./location"), exports);
19
21
  __exportStar(require("./package-protocol"), exports);
20
22
  __exportStar(require("./pi-types"), exports);
@@ -33,6 +33,11 @@ export declare namespace TaLocation {
33
33
  function readHost(input: string): HostInput;
34
34
  /** `ssh://<host><path>`; `path` absolute, or empty for the home directory. */
35
35
  function ssh(host: string, path?: string): string;
36
+ /**
37
+ * A host as a list shows it, short: the name of the machine, without the user, the port and the domain
38
+ * (`me@dev.example.com:2222` is `dev`); an address whole.
39
+ */
40
+ function hostLabel(host: string): string;
36
41
  /** The host of a remote location; undefined for this machine. */
37
42
  function host(location: string): string | undefined;
38
43
  /** The path inside its machine. */
@@ -117,6 +117,18 @@ var TaLocation;
117
117
  return `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
118
118
  }
119
119
  TaLocation.ssh = ssh;
120
+ /**
121
+ * A host as a list shows it, short: the name of the machine, without the user, the port and the domain
122
+ * (`me@dev.example.com:2222` is `dev`); an address whole.
123
+ */
124
+ function hostLabel(host) {
125
+ const name = host
126
+ .replace(/^[^@]*@/, '')
127
+ .replace(/^\[(.*)\](?::\d+)?$/, '$1')
128
+ .replace(/^([^:]*):\d+$/, '$1');
129
+ return /^[\d.]+$/.test(name) || name.includes(':') ? name : name.split('.')[0] || name;
130
+ }
131
+ TaLocation.hostLabel = hostLabel;
120
132
  /** The host of a remote location; undefined for this machine. */
121
133
  function host(location) {
122
134
  var _a;
@@ -17,8 +17,10 @@ export interface TaWebExtensionInfo {
17
17
  /**
18
18
  * `package`: a package of pi's `packages` setting (`ta install`). `directory`: a directory in `extensions/`.
19
19
  * `builtin`: a package that comes with ta; it can be turned off (setPackageEnabled), not removed.
20
+ * `temporary`: opened without installing (openTemporaryPackage): only its web extension runs, started when
21
+ * one of its pages opens, and it goes after a while unused unless kept (TaTemporaryInfo).
20
22
  */
21
- origin: 'package' | 'directory' | 'builtin';
23
+ origin: 'package' | 'directory' | 'builtin' | 'temporary';
22
24
  /** False for a built-in package that is turned off; the others are always on. */
23
25
  enabled: boolean;
24
26
  /** The source in the `packages` setting, or the directory. */
@@ -27,15 +29,51 @@ export interface TaWebExtensionInfo {
27
29
  entry: string;
28
30
  /** Changes when the file changes. */
29
31
  hash: string;
32
+ /** What the user calls its package, `pi.title` of its package.json. */
33
+ title?: TaPackageText;
34
+ /** The name of an icon of the web client's `pi.ui.icons`, `pi.icon` of its package.json. */
35
+ icon?: string;
36
+ /**
37
+ * When the web client runs it: `startup` (default) as the page loads; `open` once one of its pages
38
+ * opens, `pi.webActivation` of its package.json. A temporary one always on `open`.
39
+ */
40
+ activation: 'startup' | 'open';
41
+ /** For a temporary package. */
42
+ temporary?: TaTemporaryInfo;
43
+ }
44
+ /** Where a temporary package came from: the market, a link someone shared, or an agent that made it for the user. */
45
+ export type TaTemporaryFrom = 'market' | 'link' | 'agent';
46
+ /** A package opened without installing (TaWebExtensionInfo.origin `temporary`). */
47
+ export interface TaTemporaryInfo {
48
+ /** What it was opened from: `npm:<name>`, `git:<repository>`, a URL of a repository, a path. */
49
+ source: string;
50
+ from: TaTemporaryFrom;
51
+ /** Milliseconds since the epoch. */
52
+ openedAt: number;
53
+ usedAt: number;
54
+ /** In the user's own (the launcher's `Mine`): never cleared for want of use. */
55
+ kept: boolean;
30
56
  }
31
57
  /** What a package holds: pi extensions, web extensions, skills, prompt templates, themes. */
32
58
  export type TaPackageResource = 'extensions' | 'web' | 'skills' | 'prompts' | 'themes';
59
+ /** Text of a package for people, as `pi.title` and `pi.summary` of its package.json give it: one string, or one per language (`en`, `zh-CN`). */
60
+ export type TaPackageText = string | Readonly<Record<string, string>>;
61
+ export declare namespace TaPackageTextUtil {
62
+ /** The text in a language such as `zh-CN`: that language, else its first part (`zh`), else English, else the first there is. */
63
+ function pick(text: TaPackageText | undefined, language: string): string | undefined;
64
+ }
33
65
  /** A pi package that Ta loads, whether it has a web extension or not. */
34
66
  export interface TaPackageInfo {
35
67
  /** Stable while the package stays where it is. */
36
68
  id: string;
37
69
  /** The `name` of its package.json, or the name of its directory. */
38
70
  name: string;
71
+ /** What the user calls it, `pi.title` of its package.json; lists show {@link name} without it. */
72
+ title?: TaPackageText;
73
+ /** What it does and where it shows, in a sentence for the user, `pi.summary` of its package.json. */
74
+ summary?: TaPackageText;
75
+ /** The name of an icon of the web client's `pi.ui.icons`, `pi.icon` of its package.json. */
76
+ icon?: string;
39
77
  description?: string;
40
78
  version?: string;
41
79
  scope: 'user' | 'project';
@@ -47,6 +85,8 @@ export interface TaPackageInfo {
47
85
  source: string;
48
86
  /** Its directory, on the machine of the server. */
49
87
  root: string;
88
+ /** For a temporary package. */
89
+ temporary?: TaTemporaryInfo;
50
90
  /** What it holds, by its package.json or, without `pi` there, by the directories pi looks in. */
51
91
  resources: TaPackageResource[];
52
92
  }
@@ -89,5 +129,24 @@ export interface TaPackageServer {
89
129
  */
90
130
  getExtensionData(name: string, key: string, cwd?: string): Promise<unknown>;
91
131
  setExtensionData(name: string, key: string, value: unknown, cwd?: string): Promise<void>;
132
+ /**
133
+ * Opens a package without installing it, as a mini program is: fetched as `installPackage` does (a path is
134
+ * only noted), not added to pi's `packages` setting, so that only its web extension runs. Its web
135
+ * extensions, those of a package already installed or open from that source too.
136
+ */
137
+ openTemporaryPackage(source: string, from: TaTemporaryFrom): Promise<TaWebExtensionInfo[]>;
138
+ /** A temporary package (by its id of listPackages or of one of its web extensions) was used now, or kept or not. */
139
+ updateTemporaryPackage(id: string, change: {
140
+ used?: boolean;
141
+ kept?: boolean;
142
+ }): Promise<void>;
143
+ /**
144
+ * Installs a temporary package for the user: its source added to pi's `packages` setting, or, made by an
145
+ * agent, its directory moved to `extensions/`. Sessions pick it up on reload.
146
+ */
147
+ installTemporaryPackage(id: string): Promise<void>;
148
+ /** After how many days unused a temporary package not kept goes; 0: never. */
149
+ getTemporaryRetention(): Promise<number>;
150
+ setTemporaryRetention(days: number): Promise<void>;
92
151
  }
93
152
  //# sourceMappingURL=package-protocol.d.ts.map
@@ -1,6 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TA_PACKAGE_SERVICE = exports.TaPackageServer = void 0;
3
+ exports.TaPackageTextUtil = exports.TA_PACKAGE_SERVICE = exports.TaPackageServer = void 0;
4
4
  exports.TaPackageServer = Symbol('TaPackageServer');
5
5
  exports.TA_PACKAGE_SERVICE = 'TaPackageServer';
6
+ var TaPackageTextUtil;
7
+ (function (TaPackageTextUtil) {
8
+ /** The text in a language such as `zh-CN`: that language, else its first part (`zh`), else English, else the first there is. */
9
+ function pick(text, language) {
10
+ var _a, _b, _c, _d;
11
+ if (text === undefined || typeof text === 'string') {
12
+ return text;
13
+ }
14
+ return (_d = (_c = (_b = (_a = text[language]) !== null && _a !== void 0 ? _a : text[language.split('-')[0]]) !== null && _b !== void 0 ? _b : text.en) !== null && _c !== void 0 ? _c : text['en-US']) !== null && _d !== void 0 ? _d : Object.values(text)[0];
15
+ }
16
+ TaPackageTextUtil.pick = pick;
17
+ })(TaPackageTextUtil || (exports.TaPackageTextUtil = TaPackageTextUtil = {}));
6
18
  //# sourceMappingURL=package-protocol.js.map
@@ -25,5 +25,22 @@ export interface TaRelayServer {
25
25
  }>;
26
26
  /** The device can no longer reach this ta serve, at once. */
27
27
  unpair(deviceId: string): Promise<void>;
28
+ /**
29
+ * A link of a package of this computer (by its id of listPackages, or of one of its web extensions), for
30
+ * another computer to open it without installing: its files go from here to there through the relay, end to
31
+ * end, while this ta serve runs and the link lasts; nothing is kept on the relay. The link of before while it lasts.
32
+ */
33
+ sharePackage(id: string): Promise<TaPackageShare>;
34
+ /** The links of a package no longer work. */
35
+ unsharePackage(id: string): Promise<void>;
36
+ }
37
+ /** A package handed on by a link (TaRelayServer.sharePackage). */
38
+ export interface TaPackageShare {
39
+ /** `https://<relay>/share#…`, the key in the fragment: what `openTemporaryPackage` takes on the other computer. */
40
+ link: string;
41
+ /** Milliseconds since the epoch. */
42
+ expiresAt: number;
43
+ /** The largest package that goes, in bytes. */
44
+ maxBytes: number;
28
45
  }
29
46
  //# sourceMappingURL=relay-protocol.d.ts.map
@@ -30,6 +30,8 @@ export interface TaSettingsSnapshot {
30
30
  models: string[];
31
31
  /** The names of those of `models` that have one other than their id. */
32
32
  modelNames?: Record<string, string>;
33
+ /** By id, the names of the providers of `models` (`Kimi For Coding` for `kimi-coding`), as the lists of models group them. */
34
+ providerNames?: Record<string, string>;
33
35
  }
34
36
  /** The settings of ta in pi's `settings.json` files, on the same WebSocket as {@link TaServer}. */
35
37
  export interface TaSettingsServer {
@@ -41,6 +41,15 @@ export declare const TA_HOST_EVENT = "ta:host";
41
41
  * keeps what the file holds then.
42
42
  */
43
43
  export declare const TA_FILE_WRITE_EVENT = "ta:file-write";
44
+ /**
45
+ * Where the web client keeps the session file of the double's conversation: in the data of packages
46
+ * (TaExtensionHost.getExtensionData), under this package name and key; a JSON string, empty before the
47
+ * double first opened. The server side of a package that sends to the double reads it there.
48
+ */
49
+ export declare const TA_DOUBLE_FILE: {
50
+ readonly name: '@celljs/ta-web';
51
+ readonly key: 'assistant.file';
52
+ };
44
53
  export interface TaFileWrite {
45
54
  /** Absolute, on the machine where the session's tools work. */
46
55
  path: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TA_FILE_WRITE_EVENT = exports.TA_HOST_EVENT = void 0;
3
+ exports.TA_DOUBLE_FILE = exports.TA_FILE_WRITE_EVENT = exports.TA_HOST_EVENT = void 0;
4
4
  /**
5
5
  * The event of pi's `pi.events` by which a pi extension asks for the host of its package:
6
6
  * `pi.events.emit(TA_HOST_EVENT, { name, resolve })`. Under `ta serve` `resolve` is called at once, if
@@ -15,4 +15,10 @@ exports.TA_HOST_EVENT = 'ta:host';
15
15
  * keeps what the file holds then.
16
16
  */
17
17
  exports.TA_FILE_WRITE_EVENT = 'ta:file-write';
18
+ /**
19
+ * Where the web client keeps the session file of the double's conversation: in the data of packages
20
+ * (TaExtensionHost.getExtensionData), under this package name and key; a JSON string, empty before the
21
+ * double first opened. The server side of a package that sends to the double reads it there.
22
+ */
23
+ exports.TA_DOUBLE_FILE = { name: '@celljs/ta-web', key: 'assistant.file' };
18
24
  //# sourceMappingURL=ta-extension-host.js.map