@celljs/ta-host 4.11.0 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +3 -2
- package/README.md +3 -2
- package/esm/node/extension-data-notifier.d.ts +3 -0
- package/esm/node/extension-data-notifier.js +8 -2
- package/esm/node/extension-providers.js +1 -1
- package/esm/node/host-protocol.d.ts +20 -1
- package/esm/node/host-protocol.js +1 -0
- package/esm/node/index.d.ts +3 -0
- package/esm/node/index.js +3 -0
- package/esm/node/keep-awake.d.ts +44 -0
- package/esm/node/keep-awake.js +112 -0
- package/esm/node/package-host-extension.js +2 -0
- package/esm/node/package-hosts.d.ts +23 -1
- package/esm/node/package-hosts.js +61 -3
- package/esm/node/relay-bridge.d.ts +37 -3
- package/esm/node/relay-bridge.js +271 -10
- package/esm/node/rooms-bridge.d.ts +13 -2
- package/esm/node/rooms-bridge.js +34 -4
- package/esm/node/session-catalog.d.ts +1 -1
- package/esm/node/session-catalog.js +5 -0
- package/esm/node/session-list-feed.d.ts +11 -1
- package/esm/node/session-list-feed.js +17 -3
- package/esm/node/session-resume.d.ts +52 -0
- package/esm/node/session-resume.js +174 -0
- package/esm/node/settings-store.d.ts +3 -0
- package/esm/node/settings-store.js +22 -0
- package/esm/node/ta-errors.d.ts +1 -0
- package/esm/node/ta-errors.js +4 -0
- package/esm/node/ta-server-impl.d.ts +10 -0
- package/esm/node/ta-server-impl.js +57 -9
- package/esm/node/ta-session-factory.js +5 -2
- package/esm/node/ta-session-registry.d.ts +12 -1
- package/esm/node/ta-session-registry.js +30 -1
- package/esm/node/ta-session.d.ts +3 -0
- package/esm/node/ta-session.js +16 -0
- package/esm/node/team/authority.d.ts +19 -0
- package/esm/node/team/authority.js +79 -0
- package/esm/node/team/call-util.d.ts +23 -0
- package/esm/node/team/call-util.js +88 -0
- package/esm/node/team/connections.d.ts +15 -0
- package/esm/node/team/connections.js +81 -0
- package/esm/node/team/host-team.d.ts +13 -0
- package/esm/node/team/host-team.js +69 -0
- package/esm/node/team/index.d.ts +13 -0
- package/esm/node/team/index.js +14 -0
- package/esm/node/team/member-devices.d.ts +11 -0
- package/esm/node/team/member-devices.js +56 -0
- package/esm/node/team/package-permissions.d.ts +23 -0
- package/esm/node/team/package-permissions.js +75 -0
- package/esm/node/team/principals.d.ts +22 -0
- package/esm/node/team/principals.js +72 -0
- package/esm/node/team/run-actors.d.ts +21 -0
- package/esm/node/team/run-actors.js +100 -0
- package/esm/node/team/shared-data.d.ts +18 -0
- package/esm/node/team/shared-data.js +55 -0
- package/esm/node/team/team-calls.d.ts +33 -0
- package/esm/node/team/team-calls.js +266 -0
- package/esm/node/team/team-gate.d.ts +31 -0
- package/esm/node/team/team-gate.js +177 -0
- package/esm/node/team/team-protocol.d.ts +89 -0
- package/esm/node/team/team-protocol.js +27 -0
- package/esm/node/team/visibility.d.ts +13 -0
- package/esm/node/team/visibility.js +50 -0
- package/esm/node/terminal-service.d.ts +5 -0
- package/esm/node/terminal-service.js +11 -2
- package/lib/node/extension-data-notifier.d.ts +3 -0
- package/lib/node/extension-data-notifier.js +8 -2
- package/lib/node/extension-providers.js +1 -1
- package/lib/node/host-protocol.d.ts +20 -1
- package/lib/node/host-protocol.js +2 -1
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.js +3 -0
- package/lib/node/keep-awake.d.ts +45 -0
- package/lib/node/keep-awake.js +115 -0
- package/lib/node/package-host-extension.js +2 -0
- package/lib/node/package-hosts.d.ts +23 -1
- package/lib/node/package-hosts.js +60 -2
- package/lib/node/relay-bridge.d.ts +37 -3
- package/lib/node/relay-bridge.js +269 -8
- package/lib/node/rooms-bridge.d.ts +13 -2
- package/lib/node/rooms-bridge.js +34 -4
- package/lib/node/session-catalog.d.ts +1 -1
- package/lib/node/session-catalog.js +5 -0
- package/lib/node/session-list-feed.d.ts +11 -1
- package/lib/node/session-list-feed.js +17 -3
- package/lib/node/session-resume.d.ts +53 -0
- package/lib/node/session-resume.js +177 -0
- package/lib/node/settings-store.d.ts +3 -0
- package/lib/node/settings-store.js +22 -0
- package/lib/node/ta-errors.d.ts +1 -0
- package/lib/node/ta-errors.js +4 -0
- package/lib/node/ta-server-impl.d.ts +10 -0
- package/lib/node/ta-server-impl.js +57 -9
- package/lib/node/ta-session-factory.js +4 -1
- package/lib/node/ta-session-registry.d.ts +12 -1
- package/lib/node/ta-session-registry.js +30 -1
- package/lib/node/ta-session.d.ts +3 -0
- package/lib/node/ta-session.js +16 -0
- package/lib/node/team/authority.d.ts +20 -0
- package/lib/node/team/authority.js +82 -0
- package/lib/node/team/call-util.d.ts +24 -0
- package/lib/node/team/call-util.js +91 -0
- package/lib/node/team/connections.d.ts +16 -0
- package/lib/node/team/connections.js +84 -0
- package/lib/node/team/host-team.d.ts +14 -0
- package/lib/node/team/host-team.js +72 -0
- package/lib/node/team/index.d.ts +14 -0
- package/lib/node/team/index.js +30 -0
- package/lib/node/team/member-devices.d.ts +12 -0
- package/lib/node/team/member-devices.js +59 -0
- package/lib/node/team/package-permissions.d.ts +24 -0
- package/lib/node/team/package-permissions.js +78 -0
- package/lib/node/team/principals.d.ts +23 -0
- package/lib/node/team/principals.js +75 -0
- package/lib/node/team/run-actors.d.ts +22 -0
- package/lib/node/team/run-actors.js +103 -0
- package/lib/node/team/shared-data.d.ts +19 -0
- package/lib/node/team/shared-data.js +58 -0
- package/lib/node/team/team-calls.d.ts +34 -0
- package/lib/node/team/team-calls.js +270 -0
- package/lib/node/team/team-gate.d.ts +32 -0
- package/lib/node/team/team-gate.js +180 -0
- package/lib/node/team/team-protocol.d.ts +90 -0
- package/lib/node/team/team-protocol.js +30 -0
- package/lib/node/team/visibility.d.ts +14 -0
- package/lib/node/team/visibility.js +53 -0
- package/lib/node/terminal-service.d.ts +5 -0
- package/lib/node/terminal-service.js +11 -2
- package/package.json +14 -10
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { CODING_AGENT_OPTIONS } from '@celljs/ai-coding-agent';
|
|
13
|
+
import { Component, Value } from '@celljs/core';
|
|
14
|
+
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
15
|
+
import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
|
|
16
|
+
import { TaPermissionUtil } from '@celljs/ta-protocol';
|
|
17
|
+
import { TaPackagePermissions } from './team-protocol.js';
|
|
18
|
+
const ENABLED_MS = 5000;
|
|
19
|
+
/**
|
|
20
|
+
* What the built-in packages that are on declare of their hosts and tools (`pi.permissions` of their package.json): the
|
|
21
|
+
* knowledge stays with each package, ta serve only reads it. A package of the user's declares nothing that counts: its
|
|
22
|
+
* host and tools need as much as installing one (TA_UNDECLARED), which only who may install extensions has.
|
|
23
|
+
*/
|
|
24
|
+
let DefaultTaPackagePermissions = class DefaultTaPackagePermissions {
|
|
25
|
+
constructor() {
|
|
26
|
+
/** By the root of each package: read once, a package that comes with Ta does not change while it runs. */
|
|
27
|
+
this.manifests = new Map();
|
|
28
|
+
}
|
|
29
|
+
host(name, method, kind) {
|
|
30
|
+
return TaPermissionUtil.host(this.all().get(name), method, kind);
|
|
31
|
+
}
|
|
32
|
+
tool(name) {
|
|
33
|
+
var _a;
|
|
34
|
+
for (const manifest of this.all().values()) {
|
|
35
|
+
// Own names only: `toString` is no tool of a package.
|
|
36
|
+
const declared = new Map(Object.entries((_a = manifest.tools) !== null && _a !== void 0 ? _a : {})).get(name);
|
|
37
|
+
if (declared !== undefined) {
|
|
38
|
+
return declared;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
/** The manifests of the built-in packages on now, by name. */
|
|
44
|
+
all(now = Date.now()) {
|
|
45
|
+
var _a;
|
|
46
|
+
var _b;
|
|
47
|
+
if (!this.on || now - this.on.at > ENABLED_MS) {
|
|
48
|
+
const agentDir = (_b = (_a = this.codingAgentOptions) === null || _a === void 0 ? void 0 : _a.agentDir) !== null && _b !== void 0 ? _b : TaBrand.agentDir();
|
|
49
|
+
this.on = { at: now, byName: new Map(TaPackages.enabled(agentDir).map(pkg => [pkg.name, this.read(pkg.root)])) };
|
|
50
|
+
}
|
|
51
|
+
return this.on.byName;
|
|
52
|
+
}
|
|
53
|
+
read(root) {
|
|
54
|
+
let manifest = this.manifests.get(root);
|
|
55
|
+
if (!manifest) {
|
|
56
|
+
try {
|
|
57
|
+
manifest = TaPermissionUtil.read(JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).pi);
|
|
58
|
+
}
|
|
59
|
+
catch (_a) {
|
|
60
|
+
manifest = {};
|
|
61
|
+
}
|
|
62
|
+
this.manifests.set(root, manifest);
|
|
63
|
+
}
|
|
64
|
+
return manifest;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
__decorate([
|
|
68
|
+
Value(CODING_AGENT_OPTIONS),
|
|
69
|
+
__metadata("design:type", Object)
|
|
70
|
+
], DefaultTaPackagePermissions.prototype, "codingAgentOptions", void 0);
|
|
71
|
+
DefaultTaPackagePermissions = __decorate([
|
|
72
|
+
Component(TaPackagePermissions)
|
|
73
|
+
], DefaultTaPackagePermissions);
|
|
74
|
+
export { DefaultTaPackagePermissions };
|
|
75
|
+
//# sourceMappingURL=package-permissions.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import type { IncomingMessage } from 'node:http';
|
|
3
|
+
import { type RpcConnection } from '@celljs/rpc/lib/node';
|
|
4
|
+
import { type RelayBridge } from '../relay-bridge.js';
|
|
5
|
+
import { type TaAccess } from '../ta-access.js';
|
|
6
|
+
import { TaPrincipals } from './team-protocol.js';
|
|
7
|
+
/**
|
|
8
|
+
* Who a connection is: the owner for the token of ta serve, a page signed in and the owner's own devices; the principal a
|
|
9
|
+
* device of one let in was paired for (the relay tells which device, RelayHostUtil.localUrl); an unknown device, removed
|
|
10
|
+
* since, is no one and may do nothing. Known once per connection.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DefaultTaPrincipals implements TaPrincipals {
|
|
13
|
+
protected readonly access: TaAccess;
|
|
14
|
+
protected readonly relay: RelayBridge;
|
|
15
|
+
protected readonly known: WeakMap<object, string>;
|
|
16
|
+
protected readonly as: AsyncLocalStorage<string>;
|
|
17
|
+
of(connection: RpcConnection): string;
|
|
18
|
+
current(): string;
|
|
19
|
+
actAs<T>(principal: string, run: () => Promise<T>): Promise<T>;
|
|
20
|
+
acting(): boolean;
|
|
21
|
+
protected ofRequest(request: IncomingMessage): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
11
|
+
import { Autowired, Component } from '@celljs/core';
|
|
12
|
+
import { RpcContext } from '@celljs/rpc/lib/node';
|
|
13
|
+
import { TA_OWNER } from '@celljs/ta-protocol';
|
|
14
|
+
import { RELAY_BRIDGE } from '../relay-bridge.js';
|
|
15
|
+
import { TA_ACCESS, TaAccessUtil } from '../ta-access.js';
|
|
16
|
+
import { TaPrincipals } from './team-protocol.js';
|
|
17
|
+
/**
|
|
18
|
+
* Who a connection is: the owner for the token of ta serve, a page signed in and the owner's own devices; the principal a
|
|
19
|
+
* device of one let in was paired for (the relay tells which device, RelayHostUtil.localUrl); an unknown device, removed
|
|
20
|
+
* since, is no one and may do nothing. Known once per connection.
|
|
21
|
+
*/
|
|
22
|
+
let DefaultTaPrincipals = class DefaultTaPrincipals {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.known = new WeakMap();
|
|
25
|
+
this.as = new AsyncLocalStorage();
|
|
26
|
+
}
|
|
27
|
+
of(connection) {
|
|
28
|
+
let principal = this.known.get(connection);
|
|
29
|
+
if (principal === undefined) {
|
|
30
|
+
principal = this.ofRequest(connection.request);
|
|
31
|
+
this.known.set(connection, principal);
|
|
32
|
+
}
|
|
33
|
+
return principal;
|
|
34
|
+
}
|
|
35
|
+
current() {
|
|
36
|
+
const acted = this.as.getStore();
|
|
37
|
+
if (acted) {
|
|
38
|
+
return acted;
|
|
39
|
+
}
|
|
40
|
+
const connection = RpcContext.connection();
|
|
41
|
+
return connection ? this.of(connection) : TA_OWNER;
|
|
42
|
+
}
|
|
43
|
+
actAs(principal, run) {
|
|
44
|
+
return this.as.run(principal, run);
|
|
45
|
+
}
|
|
46
|
+
acting() {
|
|
47
|
+
return this.as.getStore() !== undefined;
|
|
48
|
+
}
|
|
49
|
+
ofRequest(request) {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
const deviceId = new URL((_a = request.url) !== null && _a !== void 0 ? _a : '/', 'http://localhost').searchParams.get('device');
|
|
52
|
+
const token = TaAccessUtil.tokenOf(request);
|
|
53
|
+
if (!deviceId || token === undefined || !TaAccessUtil.equals(token, this.access.token)) {
|
|
54
|
+
return TA_OWNER;
|
|
55
|
+
}
|
|
56
|
+
const device = this.relay.store.device(deviceId);
|
|
57
|
+
return device ? ((_b = device.member) !== null && _b !== void 0 ? _b : TA_OWNER) : `device:${deviceId}`;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
__decorate([
|
|
61
|
+
Autowired({ id: TA_ACCESS, detached: true }),
|
|
62
|
+
__metadata("design:type", Function)
|
|
63
|
+
], DefaultTaPrincipals.prototype, "access", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
Autowired({ id: RELAY_BRIDGE, detached: true }),
|
|
66
|
+
__metadata("design:type", Function)
|
|
67
|
+
], DefaultTaPrincipals.prototype, "relay", void 0);
|
|
68
|
+
DefaultTaPrincipals = __decorate([
|
|
69
|
+
Component(TaPrincipals)
|
|
70
|
+
], DefaultTaPrincipals);
|
|
71
|
+
export { DefaultTaPrincipals };
|
|
72
|
+
//# sourceMappingURL=principals.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TaSessionRegistry } from '../host-protocol.js';
|
|
2
|
+
import { type TaRunActors as RunActors, TaAuthority, TaPrincipals } from './team-protocol.js';
|
|
3
|
+
/**
|
|
4
|
+
* Who asked the run going on in each session, until it ends (docs/design/ta-team.md 5): the owner is kept too, so that a
|
|
5
|
+
* run the owner asked is told from one nobody's page asked (a package, a scheduled task). A run of those let in starts
|
|
6
|
+
* within the owner's limit of runs at once (TaAuthorizer.mayRun).
|
|
7
|
+
*/
|
|
8
|
+
export declare class DefaultTaRunActors implements RunActors {
|
|
9
|
+
protected readonly principals: TaPrincipals;
|
|
10
|
+
protected readonly authority: TaAuthority;
|
|
11
|
+
protected readonly sessions: TaSessionRegistry;
|
|
12
|
+
/** By session id. */
|
|
13
|
+
protected readonly runs: Map<string, Set<string>>;
|
|
14
|
+
protected init(): void;
|
|
15
|
+
prompted(sessionId: string): void;
|
|
16
|
+
/** Only by a call of its own to TaServer, not one a package made while serving it (an agent's conversation stays the owner's). */
|
|
17
|
+
created(sessionFile: string | undefined, cwd: string): void;
|
|
18
|
+
actorsOf(sessionFile: string): string[];
|
|
19
|
+
actorsOfSession(sessionId: string): ReadonlySet<string> | undefined;
|
|
20
|
+
stopRunsOf(principal: string): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Autowired, Component, PostConstruct } from '@celljs/core';
|
|
11
|
+
import { TA_OWNER } from '@celljs/ta-protocol';
|
|
12
|
+
import { Context } from '@celljs/web/lib/node';
|
|
13
|
+
import { TaSessionRegistry } from '../host-protocol.js';
|
|
14
|
+
import { TaErrors } from '../ta-errors.js';
|
|
15
|
+
import { TaAuthority, TaPrincipals, TaRunActors } from './team-protocol.js';
|
|
16
|
+
/**
|
|
17
|
+
* Who asked the run going on in each session, until it ends (docs/design/ta-team.md 5): the owner is kept too, so that a
|
|
18
|
+
* run the owner asked is told from one nobody's page asked (a package, a scheduled task). A run of those let in starts
|
|
19
|
+
* within the owner's limit of runs at once (TaAuthorizer.mayRun).
|
|
20
|
+
*/
|
|
21
|
+
let DefaultTaRunActors = class DefaultTaRunActors {
|
|
22
|
+
constructor() {
|
|
23
|
+
/** By session id. */
|
|
24
|
+
this.runs = new Map();
|
|
25
|
+
}
|
|
26
|
+
init() {
|
|
27
|
+
this.sessions.onSessionEvent((session, event) => {
|
|
28
|
+
if (event.type === 'agent_end') {
|
|
29
|
+
this.runs.delete(session.id);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
prompted(sessionId) {
|
|
34
|
+
const principal = this.principals.current();
|
|
35
|
+
if (principal !== TA_OWNER) {
|
|
36
|
+
const running = [...this.runs].filter(([id, actors]) => id !== sessionId && [...actors].some(actor => actor !== TA_OWNER)).length;
|
|
37
|
+
if (!this.authority.mayRun(principal, running)) {
|
|
38
|
+
throw TaErrors.limit(running);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
let actors = this.runs.get(sessionId);
|
|
42
|
+
if (!actors) {
|
|
43
|
+
actors = new Set();
|
|
44
|
+
this.runs.set(sessionId, actors);
|
|
45
|
+
}
|
|
46
|
+
actors.add(principal);
|
|
47
|
+
}
|
|
48
|
+
/** Only by a call of its own to TaServer, not one a package made while serving it (an agent's conversation stays the owner's). */
|
|
49
|
+
created(sessionFile, cwd) {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
var _c;
|
|
52
|
+
const principal = this.principals.current();
|
|
53
|
+
const direct = this.principals.acting() ||
|
|
54
|
+
/\/TaServer$/.test(((_c = (_b = (_a = Context.getCurrent()) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.url) !== null && _c !== void 0 ? _c : '').split('?')[0]);
|
|
55
|
+
if (principal !== TA_OWNER && sessionFile && direct) {
|
|
56
|
+
this.authority.created(principal, { kind: 'session', id: sessionFile, cwd });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
actorsOf(sessionFile) {
|
|
60
|
+
var _a;
|
|
61
|
+
const session = this.sessions.list().find(one => one.pi.sessionFile === sessionFile);
|
|
62
|
+
return session ? [...((_a = this.runs.get(session.id)) !== null && _a !== void 0 ? _a : [])] : [];
|
|
63
|
+
}
|
|
64
|
+
actorsOfSession(sessionId) {
|
|
65
|
+
return this.runs.get(sessionId);
|
|
66
|
+
}
|
|
67
|
+
stopRunsOf(principal) {
|
|
68
|
+
var _a;
|
|
69
|
+
for (const [id, actors] of this.runs) {
|
|
70
|
+
if (actors.has(principal)) {
|
|
71
|
+
(_a = this.sessions
|
|
72
|
+
.list()
|
|
73
|
+
.find(one => one.id === id)) === null || _a === void 0 ? void 0 : _a.runtime.session.abort().catch(() => undefined);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
__decorate([
|
|
79
|
+
Autowired(TaPrincipals),
|
|
80
|
+
__metadata("design:type", Object)
|
|
81
|
+
], DefaultTaRunActors.prototype, "principals", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
Autowired(TaAuthority),
|
|
84
|
+
__metadata("design:type", Object)
|
|
85
|
+
], DefaultTaRunActors.prototype, "authority", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
Autowired({ id: TaSessionRegistry, detached: true }),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], DefaultTaRunActors.prototype, "sessions", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
PostConstruct(),
|
|
92
|
+
__metadata("design:type", Function),
|
|
93
|
+
__metadata("design:paramtypes", []),
|
|
94
|
+
__metadata("design:returntype", void 0)
|
|
95
|
+
], DefaultTaRunActors.prototype, "init", null);
|
|
96
|
+
DefaultTaRunActors = __decorate([
|
|
97
|
+
Component(TaRunActors)
|
|
98
|
+
], DefaultTaRunActors);
|
|
99
|
+
export { DefaultTaRunActors };
|
|
100
|
+
//# sourceMappingURL=run-actors.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TaSharedData } from '@celljs/ta-protocol';
|
|
2
|
+
import { TaSharedDataRegistry } from './team-protocol.js';
|
|
3
|
+
/** The data the pages of one let in keep for themselves: under a package name of their own, never in the user's. */
|
|
4
|
+
export declare namespace MemberDataUtil {
|
|
5
|
+
/** `@ta-member.<hex of the principal>/<scope>__<name>`: a file of its own, not filling the 4 MB the user's has. */
|
|
6
|
+
function name(principal: string, name: unknown): unknown;
|
|
7
|
+
/** The principal and the package of a name of {@link name}; undefined for a name of the user's. */
|
|
8
|
+
function of(name: string): {
|
|
9
|
+
principal: string;
|
|
10
|
+
name: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** What packages declared is the Ta's of their data (TaHostTeam.shareData): read by those let in as `view` says, never written. */
|
|
14
|
+
export declare class DefaultTaSharedDataRegistry implements TaSharedDataRegistry {
|
|
15
|
+
protected readonly shared: Map<string, TaSharedData[]>;
|
|
16
|
+
add(name: string, data: TaSharedData): () => void;
|
|
17
|
+
of(name: string, key: unknown): TaSharedData | undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Component } from '@celljs/core';
|
|
8
|
+
import { TaSharedDataRegistry } from './team-protocol.js';
|
|
9
|
+
/** The scope of the data of packages kept apart for one let in (MemberDataUtil.name). */
|
|
10
|
+
const MEMBER_SCOPE = '@ta-member.';
|
|
11
|
+
/** The data the pages of one let in keep for themselves: under a package name of their own, never in the user's. */
|
|
12
|
+
export var MemberDataUtil;
|
|
13
|
+
(function (MemberDataUtil) {
|
|
14
|
+
/** `@ta-member.<hex of the principal>/<scope>__<name>`: a file of its own, not filling the 4 MB the user's has. */
|
|
15
|
+
function name(principal, name) {
|
|
16
|
+
if (typeof name !== 'string') {
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
return `${MEMBER_SCOPE}${Buffer.from(principal).toString('hex')}/${name.replace(/^@/, '').replace('/', '__')}`;
|
|
20
|
+
}
|
|
21
|
+
MemberDataUtil.name = name;
|
|
22
|
+
/** The principal and the package of a name of {@link name}; undefined for a name of the user's. */
|
|
23
|
+
function of(name) {
|
|
24
|
+
if (!name.startsWith(MEMBER_SCOPE)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const slash = name.indexOf('/');
|
|
28
|
+
const principal = Buffer.from(name.slice(MEMBER_SCOPE.length, slash), 'hex').toString();
|
|
29
|
+
const rest = name.slice(slash + 1);
|
|
30
|
+
return { principal, name: rest.includes('__') ? `@${rest.replace('__', '/')}` : rest };
|
|
31
|
+
}
|
|
32
|
+
MemberDataUtil.of = of;
|
|
33
|
+
})(MemberDataUtil || (MemberDataUtil = {}));
|
|
34
|
+
/** What packages declared is the Ta's of their data (TaHostTeam.shareData): read by those let in as `view` says, never written. */
|
|
35
|
+
let DefaultTaSharedDataRegistry = class DefaultTaSharedDataRegistry {
|
|
36
|
+
constructor() {
|
|
37
|
+
this.shared = new Map();
|
|
38
|
+
}
|
|
39
|
+
add(name, data) {
|
|
40
|
+
var _a;
|
|
41
|
+
this.shared.set(name, [...((_a = this.shared.get(name)) !== null && _a !== void 0 ? _a : []), data]);
|
|
42
|
+
return () => { var _a; return this.shared.set(name, ((_a = this.shared.get(name)) !== null && _a !== void 0 ? _a : []).filter(one => one !== data)); };
|
|
43
|
+
}
|
|
44
|
+
of(name, key) {
|
|
45
|
+
var _a;
|
|
46
|
+
return typeof key === 'string'
|
|
47
|
+
? ((_a = this.shared.get(name)) !== null && _a !== void 0 ? _a : []).find(data => data.keys.some(one => (one.endsWith('/') ? key.startsWith(one) : key === one)))
|
|
48
|
+
: undefined;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
DefaultTaSharedDataRegistry = __decorate([
|
|
52
|
+
Component(TaSharedDataRegistry)
|
|
53
|
+
], DefaultTaSharedDataRegistry);
|
|
54
|
+
export { DefaultTaSharedDataRegistry };
|
|
55
|
+
//# sourceMappingURL=shared-data.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TaResource } from '@celljs/ta-protocol';
|
|
2
|
+
/** One action on one resource. */
|
|
3
|
+
export interface TaCallNeedOne {
|
|
4
|
+
action: string;
|
|
5
|
+
resource?: TaResource;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* What a call needs of one let in: an action (on a resource), several (all of them: a file URL needs its file and the
|
|
9
|
+
* directory it opens), nothing (`anyone`: any principal let in), or nothing either and open to one holding a link of
|
|
10
|
+
* invitation too (`invite`: asking to come in).
|
|
11
|
+
*/
|
|
12
|
+
export type TaCallNeed = TaCallNeedOne | TaCallNeedOne[] | 'anyone' | 'invite';
|
|
13
|
+
/** What finding the resource of a call needs: where a session is, the default directory, what packages declare. */
|
|
14
|
+
export interface TaCallLookup {
|
|
15
|
+
session(sessionId: string): {
|
|
16
|
+
sessionFile?: string;
|
|
17
|
+
cwd: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
defaultCwd(): Promise<string>;
|
|
20
|
+
/** What a method of the host of a package needs, as it declares (TaPackagePermissions.host). */
|
|
21
|
+
packageAction(name: string, method: string, kind?: string): string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A path made plain: `..` and `.` gone, the same for a path of this machine and an `ssh://host/path` location, so
|
|
25
|
+
* that `/shared/../etc` is `/etc` before anything compares it with a folder.
|
|
26
|
+
*/
|
|
27
|
+
export declare function plainPath(path: string): string;
|
|
28
|
+
export declare namespace TaCallPermissions {
|
|
29
|
+
/** What the call needs; undefined for a call of no rule, which only the owner makes. */
|
|
30
|
+
function need(service: string, method: string, params: unknown[], lookup: TaCallLookup): Promise<TaCallNeed | undefined>;
|
|
31
|
+
/** The methods with a rule, by service: for the spec. */
|
|
32
|
+
function methods(): Record<string, string[]>;
|
|
33
|
+
}
|