@primusclaw/personal-agent-runtime 0.7.2 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +216 -86
- package/dist/types/claw/identity-lookup.d.ts +1 -1
- package/dist/types/claw/settings.d.ts +2 -1
- package/dist/types/config/aliases.d.ts +43 -0
- package/dist/types/config/env.d.ts +7 -1
- package/dist/types/config/index.d.ts +2 -1
- package/dist/types/config/secrets.d.ts +11 -1
- package/dist/types/config/settings.d.ts +1 -1
- package/dist/types/crypto/link-code.d.ts +1 -1
- package/dist/types/github/intent-reader.d.ts +3 -3
- package/dist/types/http/claw-events.d.ts +1 -1
- package/dist/types/sqlite/context.d.ts +1 -1
- package/dist/types/sqlite/database.d.ts +7 -1
- package/dist/types/sqlite/open.d.ts +2 -2
- package/dist/types/sqlite/store.d.ts +2 -2
- package/dist/types/worker/assemble.d.ts +28 -0
- package/dist/types/worker/build-info.d.ts +11 -0
- package/dist/types/worker/features-assistant.d.ts +50 -0
- package/dist/types/worker/features-base.d.ts +94 -0
- package/dist/types/worker/features-proactive.d.ts +25 -0
- package/dist/types/worker/features-remote.d.ts +13 -0
- package/dist/types/worker/features-review.d.ts +31 -0
- package/dist/types/worker/features-switches.d.ts +26 -0
- package/dist/types/worker/features-text.d.ts +38 -0
- package/dist/types/worker/features-turns.d.ts +18 -0
- package/dist/types/worker/features-w8.d.ts +20 -0
- package/dist/types/worker/features.d.ts +50 -0
- package/dist/types/worker/http.d.ts +23 -0
- package/dist/types/worker/plugins.d.ts +20 -0
- package/dist/types/worker/run-main.d.ts +3 -0
- package/dist/types/worker/runner.d.ts +36 -0
- package/dist/types/worker/startup-error.d.ts +7 -0
- package/dist/types/worker/surface-adapter.d.ts +87 -0
- package/dist/types/worker/timers.d.ts +14 -0
- package/dist/types/worker/worker-api.d.ts +70 -0
- package/dist/types/worker/worker-services.d.ts +29 -0
- package/dist/types/worker.d.ts +20 -0
- package/dist/worker.js +1684 -0
- package/package.json +7 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The worker's own settings carry the `PA_` prefix (personal agent): the store, the encryption keys, the token exchange,
|
|
3
|
+
* the review for a colleague, the per-person limits and the other settings every surface shares. They were first
|
|
4
|
+
* written with the `TEAMS_` prefix, when Teams was the only surface; those names are still read, as aliases, so a
|
|
5
|
+
* deployment that sets them keeps working unchanged. `PA_` and not a word such as `WORKER_`: the Teams surface already
|
|
6
|
+
* uses `WORKER_IDENTITY_*` for its own Azure identity, and a surface's own settings keep the surface's prefix
|
|
7
|
+
* (`TEAMS_STREAMING`, `TEAMS_AI_LABEL`), so the prefix says whose a setting is.
|
|
8
|
+
*
|
|
9
|
+
* The rule, for every pair: the `PA_` name when it is set and not blank; else the `TEAMS_` name when it is set; else the
|
|
10
|
+
* `PA_` name (unset or blank). A message about a value names the variable it was read from.
|
|
11
|
+
*/
|
|
12
|
+
import { type Logger } from "@primusclaw/personal-agent";
|
|
13
|
+
/** The prefix of the worker's own settings. */
|
|
14
|
+
export declare const SETTING_PREFIX = "PA_";
|
|
15
|
+
/** The prefix the same settings were first written with, still read as an alias. */
|
|
16
|
+
export declare const LEGACY_SETTING_PREFIX = "TEAMS_";
|
|
17
|
+
/** The settings read under both prefixes, by their name after the prefix. */
|
|
18
|
+
export declare const ALIASED_SETTINGS: readonly ["DB_PATH", "ENCRYPTION_KEYS", "CLAW_EVENTS_GONE", "ON_BEHALF_USERS", "OBSERVE_USERS", "DIRECT_CHAT", "DIRECT_CHAT_USERS", "ASSISTANT_UNDERSTANDING", "ASSISTANT_UNDERSTANDING_USERS", "GROUP_CONTEXT_MESSAGES", "GROUP_CONTEXT_HOURS", "GROUP_CONTEXT_CHARS", "GROUP_CONTEXT_GRANTED", "EXCHANGE_ENABLED", "EXCHANGE_CLIENT_ID", "EXCHANGE_CLIENT_SECRET", "EXCHANGE_TOKEN_URL", "EXCHANGE_BINDING_REQUEST_URL", "EXCHANGE_ISSUER", "EXCHANGE_AUDIENCE", "EXCHANGE_SCOPE", "EXCHANGE_FOR_CHAT", "GITHUB_REVIEW_ENABLED", "GITHUB_REVIEW_OWNERS", "REVIEW_INTENT_MODEL", "GITHUB_CREDENTIAL_URL", "GITHUB_CLIENT_ID", "USER_MESSAGE_LIMIT", "USER_MESSAGE_WINDOW_SECONDS", "USER_MAX_CONCURRENT_TASKS", "LINK_MAX_FAILURES_PER_USER", "LINK_MAX_FAILURES_GLOBAL", "LINK_ATTEMPT_WINDOW_SECONDS", "LIMIT_PR_REVIEW", "LIMIT_PR_MERGE", "LIMIT_APPROVAL", "LIMIT_REMOTE_AGENT"];
|
|
19
|
+
/** The pairs: `PA_` name -> the `TEAMS_` name still read when it is not set. */
|
|
20
|
+
export declare const SETTING_ALIASES: ReadonlyMap<string, string>;
|
|
21
|
+
type Env = Readonly<Record<string, string | undefined>>;
|
|
22
|
+
/**
|
|
23
|
+
* The variable a setting is read from: `name` may be either name of a pair (or any other setting, read as it is). The
|
|
24
|
+
* `PA_` name when it is set and not blank, else the `TEAMS_` name when it is present, else the `PA_` name.
|
|
25
|
+
*/
|
|
26
|
+
export declare function settingSource(env: Env, name: string): string;
|
|
27
|
+
/** The value of a setting under the alias rule (undefined: neither name is present). */
|
|
28
|
+
export declare function settingValue(env: Env, name: string): string | undefined;
|
|
29
|
+
/** A legacy name in use: the one read, or one set beside its `PA_` name and ignored. */
|
|
30
|
+
export interface LegacySetting {
|
|
31
|
+
readonly legacy: string;
|
|
32
|
+
readonly neutral: string;
|
|
33
|
+
/** The `PA_` name is set too, so the `TEAMS_` value is not read. */
|
|
34
|
+
readonly ignored: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** The `TEAMS_` names this environment sets (not blank) of the settings that now carry `PA_`. */
|
|
37
|
+
export declare function legacySettings(env: Env): LegacySetting[];
|
|
38
|
+
/**
|
|
39
|
+
* One warning at start for the `TEAMS_` names in use, naming the `PA_` name of each (never a value: some are secrets);
|
|
40
|
+
* and one for each `TEAMS_` name that is set beside its `PA_` name and so not read. Nothing when none is in use.
|
|
41
|
+
*/
|
|
42
|
+
export declare function warnLegacySettings(env: Env, logger: Logger): void;
|
|
43
|
+
export {};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/** The process environment, or a test's. */
|
|
2
2
|
export type Env = Readonly<Record<string, string | undefined>>;
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Reads settings out of an environment, with the worker's rules: a typo stops the worker, it never picks a value. A
|
|
5
|
+
* setting that has a `PA_` name and an older `TEAMS_` name is read under either (`settingSource`), and a message about
|
|
6
|
+
* its value names the variable it was read from.
|
|
7
|
+
*/
|
|
4
8
|
export declare class EnvReader {
|
|
5
9
|
readonly env: Env;
|
|
6
10
|
constructor(env: Env);
|
|
11
|
+
/** The variable `name` is read from (the `PA_` or the `TEAMS_` name of a pair; any other name as it is). */
|
|
12
|
+
source(name: string): string;
|
|
7
13
|
/** The raw value ("" unset). */
|
|
8
14
|
raw(name: string, fallback?: string): string;
|
|
9
15
|
/** The value without surrounding white space ("" unset). */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { ALIASED_SETTINGS, LEGACY_SETTING_PREFIX, SETTING_ALIASES, SETTING_PREFIX, legacySettings, settingSource, settingValue, warnLegacySettings, type LegacySetting, } from "./aliases.js";
|
|
1
2
|
export { EnvReader, pyRepr, withoutTrailingSlash, type Env } from "./env.js";
|
|
2
|
-
export { ENV_NAMES, EnvSecretSource, secretsSourceOf, wantedSecrets } from "./secrets.js";
|
|
3
|
+
export { ENV_NAMES, EnvSecretSource, SECRET_SETTING_NAMES, secretsSourceOf, wantedSecrets } from "./secrets.js";
|
|
3
4
|
export { ASSISTANT_REPLY_WINDOW_SECONDS, GITHUB_CLI_CLIENT_ID, readSettings } from "./settings.js";
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { type SecretName, type SecretSource, type SecretsSourceName } from "@primusclaw/personal-agent";
|
|
2
2
|
import { type Env } from "./env.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Where SECRETS_SOURCE=env finds each secret: an environment variable (its `PA_` name, or the older `TEAMS_` one, as
|
|
5
|
+
* `settingSource` reads them), or (the GitHub App's key) the file it names.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SECRET_SETTING_NAMES: Readonly<Record<SecretName, string>>;
|
|
8
|
+
/**
|
|
9
|
+
* The environment variable of each secret as 0.8.0 and earlier named it.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated The worker reads `SECRET_SETTING_NAMES` (the `PA_` names, with these `TEAMS_` ones as their older
|
|
12
|
+
* aliases). Kept, with its values, for callers of 0.8.0 and earlier.
|
|
13
|
+
*/
|
|
4
14
|
export declare const ENV_NAMES: Readonly<Record<SecretName, string>>;
|
|
5
15
|
/** SECRETS_SOURCE: env (the default) or keyvault; a typo stops the worker. */
|
|
6
16
|
export declare function secretsSourceOf(env: Env): SecretsSourceName;
|
|
@@ -4,7 +4,7 @@ import { type Env } from "./env.js";
|
|
|
4
4
|
export declare const GITHUB_CLI_CLIENT_ID = "178c6fc778ccc68e1d6a";
|
|
5
5
|
/** The default of ASSISTANT_REPLY_WINDOW_SECONDS. */
|
|
6
6
|
export declare const ASSISTANT_REPLY_WINDOW_SECONDS: number;
|
|
7
|
-
/** The most messages
|
|
7
|
+
/** The most messages PA_GROUP_CONTEXT_MESSAGES may keep per group chat. */
|
|
8
8
|
export declare const MAX_GROUP_CONTEXT_MESSAGES = 200;
|
|
9
9
|
/**
|
|
10
10
|
* The worker's channel-neutral settings from the environment (the Python worker's `Settings.from_env`, without the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The label the key is derived under. A new label is a new key: every pending code is void. */
|
|
2
2
|
export declare const LINK_HASH_LABEL = "primusclaw-teams/link-code-hmac/v1";
|
|
3
|
-
/** The HMAC key link codes are hashed under, derived from one Fernet key of
|
|
3
|
+
/** The HMAC key link codes are hashed under, derived from one Fernet key of PA_ENCRYPTION_KEYS. */
|
|
4
4
|
export declare function linkHashKey(fernetKey: string): Uint8Array;
|
|
5
5
|
/** A link code as it is stored (hex). */
|
|
6
6
|
export declare function hashLinkCode(code: string, key: Uint8Array): string;
|
|
@@ -21,8 +21,8 @@ export declare class GatewayIntentReader implements IntentReader {
|
|
|
21
21
|
private readonly url;
|
|
22
22
|
private readonly fetchImpl;
|
|
23
23
|
constructor(options: IntentReaderOptions);
|
|
24
|
-
read(key: string, text: string, mentions: readonly ListedMention[]): Promise<Record<string, unknown> | undefined>;
|
|
25
|
-
readMode(key: string, text: string): Promise<Record<string, unknown> | undefined>;
|
|
26
|
-
readAnswer(key: string, text: string, pending: readonly Readonly<Record<string, string>>[]): Promise<Record<string, unknown> | undefined>;
|
|
24
|
+
read(key: string, text: string, mentions: readonly ListedMention[], channel: string): Promise<Record<string, unknown> | undefined>;
|
|
25
|
+
readMode(key: string, text: string, channel: string): Promise<Record<string, unknown> | undefined>;
|
|
26
|
+
readAnswer(key: string, text: string, pending: readonly Readonly<Record<string, string>>[], channel: string): Promise<Record<string, unknown> | undefined>;
|
|
27
27
|
private complete;
|
|
28
28
|
}
|
|
@@ -15,7 +15,7 @@ export interface ClawEventsDeps {
|
|
|
15
15
|
readonly claims: Pick<IdempotencyRepository, "claimEvent" | "finishEvent" | "releaseEvent">;
|
|
16
16
|
readonly deliver: EventSink;
|
|
17
17
|
readonly clock: Clock;
|
|
18
|
-
/**
|
|
18
|
+
/** PA_CLAW_EVENTS_GONE: an event for a person with no chat here is answered 410 (else 200 "dropped", for an older Claw). */
|
|
19
19
|
readonly gone: boolean;
|
|
20
20
|
readonly metrics?: Pick<MetricsPort, "eventDelivered">;
|
|
21
21
|
readonly logger?: Logger;
|
|
@@ -6,7 +6,7 @@ import type { Database } from "./database.js";
|
|
|
6
6
|
export type SecurityEventFields = Readonly<Record<string, string | number | undefined>>;
|
|
7
7
|
export type SecurityEventSink = (event: "link_attempt" | "link_lockout", fields: SecurityEventFields) => void;
|
|
8
8
|
/**
|
|
9
|
-
* The keys of
|
|
9
|
+
* The keys of PA_ENCRYPTION_KEYS: the first encrypts and hashes new link codes, every one decrypts and finds a code
|
|
10
10
|
* (adding a key at the head does not void the codes of the last 10 minutes).
|
|
11
11
|
*/
|
|
12
12
|
export declare class StoreSecrets {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one SQLite connection a store works on, with typed statement helpers. Opened as the Python worker opens it:
|
|
3
|
-
* autocommit (`isolation_level=None`), WAL, and a 5 s busy timeout (`sqlite3.connect`'s default).
|
|
3
|
+
* autocommit (`isolation_level=None`), WAL, and a 5 s busy timeout (`sqlite3.connect`'s default). Unlike it, a commit is not
|
|
4
|
+
* fsynced on its own (`synchronous=NORMAL`, below).
|
|
4
5
|
*/
|
|
5
6
|
import { type SQLInputValue } from "node:sqlite";
|
|
6
7
|
export type SqlValue = SQLInputValue;
|
|
@@ -9,6 +10,11 @@ export type Row = Readonly<Record<string, SqlValue>>;
|
|
|
9
10
|
export declare class Database {
|
|
10
11
|
#private;
|
|
11
12
|
constructor(path: string);
|
|
13
|
+
/**
|
|
14
|
+
* `write` with each commit synced to disk (`synchronous=FULL`): for what is acknowledged as kept before it is used. Inside an
|
|
15
|
+
* open transaction SQLite refuses to change the setting, so there `write` just runs and its commit is the transaction's.
|
|
16
|
+
*/
|
|
17
|
+
durably<T>(write: () => T): T;
|
|
12
18
|
/** Several statements, no parameters (DDL). */
|
|
13
19
|
exec(sql: string): void;
|
|
14
20
|
/** Rows changed. */
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import type { Clock, LinkLimits, Logger, Random } from "@primusclaw/personal-agent";
|
|
6
6
|
import type { SecurityEventSink } from "./context.js";
|
|
7
7
|
import { SqliteStore } from "./store.js";
|
|
8
|
-
/** The settings the store is opened with; the configuration's own fields (
|
|
9
|
-
*
|
|
8
|
+
/** The settings the store is opened with; the configuration's own fields (PA_DB_PATH, PA_ENCRYPTION_KEYS, the
|
|
9
|
+
* PA_LINK_* limits), so a worker's settings object is passed as it is. */
|
|
10
10
|
export interface WorkerStoreSettings {
|
|
11
11
|
readonly dbPath: string;
|
|
12
12
|
readonly encryptionKeys: readonly string[];
|
|
@@ -24,9 +24,9 @@ import { SqliteRepoHistoryRepository, SqliteSessionRepository } from "./session-
|
|
|
24
24
|
import { SqliteTurnAnswerRepository } from "./turn-repository.js";
|
|
25
25
|
export declare const DEFAULT_LINK_LIMITS: LinkLimits;
|
|
26
26
|
export interface SqliteStoreOptions {
|
|
27
|
-
/** The database file (`
|
|
27
|
+
/** The database file (`PA_DB_PATH`), or ":memory:". */
|
|
28
28
|
readonly path: string;
|
|
29
|
-
/**
|
|
29
|
+
/** PA_ENCRYPTION_KEYS: the first encrypts, all decrypt. At least one. */
|
|
30
30
|
readonly encryptionKeys: readonly string[];
|
|
31
31
|
readonly clock?: Clock;
|
|
32
32
|
readonly random?: Random;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The worker process on a surface (the Python worker's `main.run`): secrets, settings, the store, the Claw client, the
|
|
3
|
+
* surface's outbound side, the features behind the router, the HTTP endpoints and /metrics, the surface's inbound side, and
|
|
4
|
+
* the features' timers. Nothing runs until `run`. What is the surface's own (its settings, how it is reached, where its
|
|
5
|
+
* events come from) is its `SurfaceAdapter`'s.
|
|
6
|
+
*/
|
|
7
|
+
import { InboundStats, type MetricsPort, type IntegrationRegistry, type Integrations, type Plugins, type SecretName } from "@primusclaw/personal-agent";
|
|
8
|
+
import { PrometheusMetrics } from "@primusclaw/personal-agent-runtime";
|
|
9
|
+
import type { SurfaceAdapter } from "./surface-adapter.js";
|
|
10
|
+
import type { PluginFactory, Worker, WorkerEnv, WorkerOptions } from "./worker-api.js";
|
|
11
|
+
/**
|
|
12
|
+
* The metrics, with the inbound path also counted for its `inbound_stats` line (Python `InboundStats(metrics=...)`: one line
|
|
13
|
+
* a minute of what was handled, how long it waited and took, what failed and what a limit refused).
|
|
14
|
+
*/
|
|
15
|
+
export declare function withInboundStats(prometheus: PrometheusMetrics, stats: InboundStats): MetricsPort;
|
|
16
|
+
/** The secrets from the environment, the one source a surface without its own `loadSecrets` has. */
|
|
17
|
+
export declare function envSecrets(env: WorkerEnv, names: readonly SecretName[]): Promise<ReadonlyMap<SecretName, string>>;
|
|
18
|
+
/**
|
|
19
|
+
* `integrations` with what `register` adds to them (`WorkerOptions.registerIntegrations`): a registry that starts with
|
|
20
|
+
* every server and line already there, in their order, then takes the deployment's. Without `register`, `integrations`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function withRegistered(integrations: Integrations, register: ((registry: IntegrationRegistry) => void) | undefined): Integrations;
|
|
23
|
+
/**
|
|
24
|
+
* Build the worker on the surface `adapter` from `env` with `plugins` (or a factory that builds them with the worker's
|
|
25
|
+
* services). Rejects at start, before anything is served, when the settings are not usable: a worker that starts must be
|
|
26
|
+
* able to answer. A surface package's own `buildWorker` is this with its adapter.
|
|
27
|
+
*/
|
|
28
|
+
export declare function assembleWorker(adapter: SurfaceAdapter, env: WorkerEnv, plugins: Plugins | PluginFactory, options?: WorkerOptions): Promise<Worker>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `personal_agent_build_info`: which build a running worker is, on /metrics (the `*_build_info` convention: a gauge that
|
|
3
|
+
* is always 1, the build in its labels). `version` is the surface package's own version (what npm and the image were
|
|
4
|
+
* released as; "unknown" when its package.json cannot be read), `node` the Node.js version it runs on. A deployment
|
|
5
|
+
* checks that what runs is what it pinned by reading this line.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BUILD_INFO_METRIC = "personal_agent_build_info";
|
|
8
|
+
/** The metric's lines (HELP, TYPE and the sample), each ending in a newline. */
|
|
9
|
+
export declare function buildInfoText(version: string, node: string): string;
|
|
10
|
+
/** `render`'s text with the build info appended (after a newline, if the text lacks its last one). */
|
|
11
|
+
export declare function withBuildInfo(render: () => string, info: string): () => string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The person's assistant as the worker runs it (Python `Agent.__init__`: `Subscriptions`, `Assistant`, and the buttons of its
|
|
3
|
+
* cards): the subscription keeper (only with PROACTIVE_ENABLED, which gives NOTIFY_WEBHOOK_URL), the chat that talks to the
|
|
4
|
+
* assistant, the board, the work item and watch buttons, and the commands the assistant puts to the person.
|
|
5
|
+
*/
|
|
6
|
+
import type { ClickHandler, Integrations } from "@primusclaw/personal-agent";
|
|
7
|
+
import { AssistantActions, AssistantChatService, Board, DirectChat, Receipts, remoteView, SubscriptionKeeper } from "@primusclaw/personal-agent";
|
|
8
|
+
import type { AssemblyBase, ReplyStyle, RouterHooks } from "./features-base.js";
|
|
9
|
+
/** The router's test of a command typed whole (`understanding.exact_command`). */
|
|
10
|
+
export declare const isExactCommand: (text: string) => boolean;
|
|
11
|
+
export interface AssistantParts {
|
|
12
|
+
/** undefined: notifications are off (no NOTIFY_WEBHOOK_URL). */
|
|
13
|
+
readonly subs: SubscriptionKeeper | undefined;
|
|
14
|
+
readonly chat: AssistantChatService;
|
|
15
|
+
readonly board: Board;
|
|
16
|
+
readonly receipts: Receipts;
|
|
17
|
+
readonly directChat: DirectChat;
|
|
18
|
+
readonly actions: AssistantActions;
|
|
19
|
+
readonly clicks: readonly ClickHandler[];
|
|
20
|
+
}
|
|
21
|
+
/** The approval card of a request an agent on the person's machine waits on (W6b's view). */
|
|
22
|
+
export declare function remoteAskCard(request: Parameters<ConstructorParameters<typeof Board>[0]["remoteAsk"]>[0]): {
|
|
23
|
+
body: {
|
|
24
|
+
type: "view";
|
|
25
|
+
view: {
|
|
26
|
+
name: "terminalAsk";
|
|
27
|
+
model: remoteView.TerminalAskView;
|
|
28
|
+
};
|
|
29
|
+
fallbackText: string;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
body: {
|
|
33
|
+
type: "view";
|
|
34
|
+
view: {
|
|
35
|
+
name: "remoteAsk";
|
|
36
|
+
model: remoteView.RemoteAskView;
|
|
37
|
+
};
|
|
38
|
+
fallbackText: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export interface AssistantInputs {
|
|
42
|
+
readonly style: ReplyStyle;
|
|
43
|
+
readonly integrations: Integrations;
|
|
44
|
+
/** A review the assistant handed back (`review_for_other`): to the review service, "dropped" without it. */
|
|
45
|
+
readonly reviewHandoff: (userId: string, event: Readonly<Record<string, unknown>>) => "delivered" | "dropped";
|
|
46
|
+
/** NOTIFY_WEBHOOK_URL ("" off). */
|
|
47
|
+
readonly notifyUrl: string;
|
|
48
|
+
readonly hooks: RouterHooks;
|
|
49
|
+
}
|
|
50
|
+
export declare function assistantParts(base: AssemblyBase, inputs: AssistantInputs): AssistantParts;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the features behind the router are built from (the process's ports and settings), and the hooks into the router a
|
|
3
|
+
* feature needs once the router exists: the router is built from the features, and some features call back into it.
|
|
4
|
+
*/
|
|
5
|
+
import type { ClawPort, ConversationKind, ConversationRef, InboundMessage, JsonObject, Clock, Logger, MetricsPort, Plugins, Random, RequestScope, SecurityLog, Settings, Surface, TokenExchange } from "@primusclaw/personal-agent";
|
|
6
|
+
import type { ChatLog, SqliteStore } from "@primusclaw/personal-agent-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* How replies look on the surface: the switches of its reply style that the features read (the surface reads the rest,
|
|
9
|
+
* such as Teams' AI label, itself). Each is the surface's own setting; a surface that has no such thing turns it off.
|
|
10
|
+
*/
|
|
11
|
+
export interface ReplyStyle {
|
|
12
|
+
/** The agent's visible text is streamed into the answer while a turn runs. */
|
|
13
|
+
readonly streamText: boolean;
|
|
14
|
+
/** The assistant's receipt, its live steps and its streamed words. */
|
|
15
|
+
readonly assistantReceipt: boolean;
|
|
16
|
+
readonly assistantProgress: boolean;
|
|
17
|
+
readonly assistantStreamSay: boolean;
|
|
18
|
+
/** An answer carries the worker's own thumbs on phones (the router's `ownThumbsMobile`). */
|
|
19
|
+
readonly ownThumbsMobile: boolean;
|
|
20
|
+
readonly suggestedReplies: boolean;
|
|
21
|
+
readonly citations: boolean;
|
|
22
|
+
/** Whether a turn shows the surface's live status in this kind of chat. */
|
|
23
|
+
streamsIn(kind: ConversationKind): boolean;
|
|
24
|
+
}
|
|
25
|
+
/** What the features read of the surface besides its port: its reply style, how a stored reference is read back, its words. */
|
|
26
|
+
export interface SurfaceShape {
|
|
27
|
+
readonly style: ReplyStyle;
|
|
28
|
+
/**
|
|
29
|
+
* Where a person who has not added the bot yet can add it (a link the surface's people can open; "" for none): what a
|
|
30
|
+
* colleague asked to review is pointed at.
|
|
31
|
+
*/
|
|
32
|
+
readonly installHintUrl: string;
|
|
33
|
+
/** A stored conversation reference back as core's `ConversationRef`; undefined when it names none. Never throws. */
|
|
34
|
+
restoreRef(stored: JsonObject): ConversationRef | undefined;
|
|
35
|
+
/** A stored reference as the surface posts to it: one that names no conversation still gets one (its send then fails). */
|
|
36
|
+
refOf(stored: JsonObject): ConversationRef;
|
|
37
|
+
/**
|
|
38
|
+
* The surface's fields a followed review keeps to open the reviewer's chat again after a restart, from the chat the
|
|
39
|
+
* review was asked in (Teams: service_url, tenant, bot_id).
|
|
40
|
+
*/
|
|
41
|
+
followWire(asked: ConversationRef): Readonly<Record<string, string>>;
|
|
42
|
+
/**
|
|
43
|
+
* The surface's id on the Claw wire ("teams", "slack"): sent as the person's notification subscription's `surface`, so
|
|
44
|
+
* Claw sends an assistant reply back to the surface the message came from.
|
|
45
|
+
*/
|
|
46
|
+
readonly surfaceId: string;
|
|
47
|
+
/** The surface's name as people know it ("Teams"): what a report's words and an unreadable file's line call it. */
|
|
48
|
+
readonly channelName: string;
|
|
49
|
+
/** The build the worker runs (the surface package's version): what a report names. */
|
|
50
|
+
readonly version: string;
|
|
51
|
+
}
|
|
52
|
+
export interface AssemblyBase {
|
|
53
|
+
/** Core's settings (`readSettings`). */
|
|
54
|
+
readonly settings: Settings;
|
|
55
|
+
/** What the features read of the surface besides its port (`SurfaceShape`). */
|
|
56
|
+
readonly shape: SurfaceShape;
|
|
57
|
+
readonly store: SqliteStore;
|
|
58
|
+
readonly claw: ClawPort;
|
|
59
|
+
/** The channel (the worker's surface, such as Teams'; a test's fake surface). */
|
|
60
|
+
readonly surface: Surface;
|
|
61
|
+
readonly clock: Clock;
|
|
62
|
+
readonly random: Random;
|
|
63
|
+
readonly logger: Logger;
|
|
64
|
+
/** What the platform and GitHub clients send with (the global `fetch`; a test's fake). */
|
|
65
|
+
readonly fetch: typeof fetch;
|
|
66
|
+
readonly metrics: MetricsPort;
|
|
67
|
+
readonly securityLog: SecurityLog;
|
|
68
|
+
/** The one request scope (runtime `alsRequestScope`): the router enters it per inbound event, everything else reads it. */
|
|
69
|
+
readonly requestScope: RequestScope;
|
|
70
|
+
/** The last log lines of each chat, for a report's scene (Python `feedback.LogBuffer`). */
|
|
71
|
+
readonly chatLog: ChatLog;
|
|
72
|
+
readonly plugins: Plugins;
|
|
73
|
+
readonly exchange: TokenExchange;
|
|
74
|
+
/** The switches the Python worker's `main.py` read from the environment itself (`features-switches.ts`). */
|
|
75
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
76
|
+
}
|
|
77
|
+
/** What the features ask of the router, bound once it is built (a call before then is a defect of the assembly). */
|
|
78
|
+
export interface RouterHooks {
|
|
79
|
+
/** A chat turn of the old kind is running in the person's 1:1 chat (`Router.hasPersonalTurn`). */
|
|
80
|
+
legacyTurn(userId: string): boolean;
|
|
81
|
+
/** A work item was stopped from its card: whatever follows it here ends as stopped (`Agent._item_stopped`). */
|
|
82
|
+
itemStopped(itemId: string): void;
|
|
83
|
+
/** The person pressed Deny on an approval of the chat's running turn (`turn.tool_denied`). */
|
|
84
|
+
toolDenied(userId: string, scope: string): void;
|
|
85
|
+
/** `text` carried out exactly as typed, with `key`, in `conversation` (`Agent._command`). */
|
|
86
|
+
runCommand(text: string, sender: SenderOf, conversation: ConversationOf, key: string): Promise<boolean>;
|
|
87
|
+
/** What reads Claw for a person with nobody to ask (`Agent._background_credential`); undefined: none. */
|
|
88
|
+
background(userId: string): Promise<string | undefined>;
|
|
89
|
+
/** `message` handled as one the person typed (`Router.handle`): what a choice card's Send sends. */
|
|
90
|
+
typed(message: InboundMessage): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
type SenderOf = Parameters<import("@primusclaw/personal-agent").Router["chat"]>[0];
|
|
93
|
+
type ConversationOf = Parameters<import("@primusclaw/personal-agent").Router["chat"]>[1];
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unasked messages (Python `proactive.Proactive`, as `link_api.build_app` and `Agent.__init__` build it): what Claw's events
|
|
3
|
+
* become in the chat, what quiet hours and /pause hold and later release, approval cards sent again, and the two views of it
|
|
4
|
+
* the router and the remote agents read (`ProactiveHold`, `FollowReach`).
|
|
5
|
+
*/
|
|
6
|
+
import type { Conversation, FollowReach, JsonObject, ProactiveHold, PublicErrors, Router } from "@primusclaw/personal-agent";
|
|
7
|
+
import { Proactive, Release } from "@primusclaw/personal-agent";
|
|
8
|
+
import type { AssistantParts } from "./features-assistant.js";
|
|
9
|
+
import type { AssemblyBase, ReplyStyle } from "./features-base.js";
|
|
10
|
+
export declare function conversationFor(base: Pick<AssemblyBase, "surface" | "shape">): (reference: JsonObject) => Conversation;
|
|
11
|
+
export interface ProactiveParts {
|
|
12
|
+
readonly proactive: Proactive;
|
|
13
|
+
readonly release: Release;
|
|
14
|
+
}
|
|
15
|
+
export declare function proactiveParts(base: AssemblyBase, style: ReplyStyle, assistant: Pick<AssistantParts, "receipts" | "directChat">, errors: PublicErrors, router?: () => Router): ProactiveParts;
|
|
16
|
+
/** The event claim key prefix of a turn whose identity card was sent (`identityAfterRefusal`). */
|
|
17
|
+
export declare const IDENTITY_REFUSED_PREFIX = "identity-refused:";
|
|
18
|
+
/** What the router reads of quiet hours and /pause (`muted` as a word or null, `release` on /resume). */
|
|
19
|
+
export declare function proactiveHold(parts: ProactiveParts): ProactiveHold;
|
|
20
|
+
/**
|
|
21
|
+
* What the remote agents' follower reads of it. Python's follower hands Proactive its chat key as the person (`self.aad_id`
|
|
22
|
+
* is the chat key: the person for a 1:1 chat, `<person>#<group>` for a group binding), so the same key is passed on here
|
|
23
|
+
* unchanged; the event id of a held message is a fresh uuid4 hex, as Python's `hold_remote` makes it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function followReach(parts: ProactiveParts, base: Pick<AssemblyBase, "random">): FollowReach;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DirectChat, FollowReach, PublicErrors } from "@primusclaw/personal-agent";
|
|
2
|
+
import { Guardrails, RemoteAgents } from "@primusclaw/personal-agent";
|
|
3
|
+
import type { AssemblyBase, RouterHooks } from "./features-base.js";
|
|
4
|
+
import type { FeatureSwitches } from "./features-switches.js";
|
|
5
|
+
export interface RemoteInputs {
|
|
6
|
+
readonly switches: FeatureSwitches;
|
|
7
|
+
readonly guard: Guardrails;
|
|
8
|
+
readonly reach: FollowReach;
|
|
9
|
+
readonly errors: PublicErrors;
|
|
10
|
+
readonly directChat: DirectChat;
|
|
11
|
+
readonly hooks: RouterHooks;
|
|
12
|
+
}
|
|
13
|
+
export declare function remoteAgents(base: AssemblyBase, inputs: RemoteInputs): RemoteAgents;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The review delegation (PA_GITHUB_REVIEW_ENABLED), as the Python worker's `main.run` builds `GithubReview` and
|
|
3
|
+
* `Agent.__init__` attaches it: the identity service's GitHub credentials, the device flow `/github` connects with, the
|
|
4
|
+
* public pull request reader, the request reader on the platform's model gateway (PA_REVIEW_INTENT_MODEL), and the chat
|
|
5
|
+
* it runs in (its turns start on the router, its onboarding and connect cards are the router's). What it gives back: the
|
|
6
|
+
* router's GitHub part, its handlers, the handoff the assistant can send back, the follows it takes up again at start, the
|
|
7
|
+
* open review cards it sweeps, and the stopped items it hears of.
|
|
8
|
+
*/
|
|
9
|
+
import { GithubReview, ReviewHandoffAction, type Guardrails, type PostWorkCard, type PublicErrors, type Router, type SubscriptionKeeper } from "@primusclaw/personal-agent";
|
|
10
|
+
import type { AssistantParts } from "./features-assistant.js";
|
|
11
|
+
import type { AssemblyBase } from "./features-base.js";
|
|
12
|
+
/** How often open review cards are checked for an item that is over (Python `CARD_SWEEP_SECONDS`, core `CARD_SWEEP_MS`). */
|
|
13
|
+
export declare const REVIEW_CARD_SWEEP_MS = 120000;
|
|
14
|
+
export interface ReviewInputs {
|
|
15
|
+
readonly guard: Pick<Guardrails, "take" | "giveBack">;
|
|
16
|
+
readonly errors: PublicErrors;
|
|
17
|
+
/** The router, once it is built (the service starts its turns there). */
|
|
18
|
+
readonly router: () => Router;
|
|
19
|
+
readonly subs: SubscriptionKeeper | undefined;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A work item's card in the reviewer's chat when a review waits for them (Python `_tell_reviewer_waiting`: `work_card`,
|
|
23
|
+
* then the card is placed so it is ended with its item).
|
|
24
|
+
*/
|
|
25
|
+
export declare function workCardPoster(base: Pick<AssemblyBase, "store">): PostWorkCard;
|
|
26
|
+
export interface ReviewParts {
|
|
27
|
+
readonly service: GithubReview;
|
|
28
|
+
readonly handoff: ReviewHandoffAction;
|
|
29
|
+
}
|
|
30
|
+
/** The review service and the handoff the assistant sends back; undefined with PA_GITHUB_REVIEW_ENABLED off. */
|
|
31
|
+
export declare function reviewParts(base: AssemblyBase, inputs: ReviewInputs, assistant: Pick<AssistantParts, "receipts" | "chat">): ReviewParts | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type Env = Readonly<Record<string, string | undefined>>;
|
|
2
|
+
export interface FeatureSwitches {
|
|
3
|
+
/** BRIEF_ENABLED == "1": `/brief` (it needs Claw's trigger API). */
|
|
4
|
+
readonly brief: boolean;
|
|
5
|
+
/** ASSISTANT_SCHEDULES_ENABLED == "1". */
|
|
6
|
+
readonly schedules: boolean;
|
|
7
|
+
/** ASSISTANT_JOB_WATCH_ENABLED == "1". */
|
|
8
|
+
readonly jobWatch: boolean;
|
|
9
|
+
/** REMOTE_AGENTS_ENABLED == "1". */
|
|
10
|
+
readonly remoteAgents: boolean;
|
|
11
|
+
/** An attached chat hears its agent between turns (`remote_push_wanted`). */
|
|
12
|
+
readonly remotePush: boolean;
|
|
13
|
+
/** REMOTE_WINDOW_DEFAULT: "chat", or "card" for anything else. */
|
|
14
|
+
readonly remoteWindow: "card" | "chat";
|
|
15
|
+
/** PROACTIVE_ENABLED == "1". */
|
|
16
|
+
readonly proactive: boolean;
|
|
17
|
+
/** Where Claw sends this worker's events ("" when proactive messages are off: no subscriptions at all). */
|
|
18
|
+
readonly notifyUrl: string;
|
|
19
|
+
}
|
|
20
|
+
/** NOTIFY_WEBHOOK_URL, required with PROACTIVE_ENABLED and ignored without it (`notify_url_from_env`). */
|
|
21
|
+
export declare function notifyUrlFromEnv(proactive: boolean, raw: string): string;
|
|
22
|
+
/** On unless REMOTE_PUSH_ENABLED says off, and only with PROACTIVE_ENABLED (`remote_push_wanted`). */
|
|
23
|
+
export declare function remotePushWanted(proactive: boolean, raw: string): boolean;
|
|
24
|
+
/** "chat" when REMOTE_WINDOW_DEFAULT says so, else "card" (`remote_window_default`). */
|
|
25
|
+
export declare function remoteWindowDefault(raw: string): "card" | "chat";
|
|
26
|
+
export declare function featureSwitches(env: Env): FeatureSwitches;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The router's small readers, built from core's pure functions: what a message carries besides its words (quotes, links,
|
|
3
|
+
* files the surface gave no way to fetch), the per-person limits, the channel context a message to the assistant carries, the
|
|
4
|
+
* note card a settled click ends as, `/whoami`'s connection lines, and fetching a message's files through the surface.
|
|
5
|
+
*/
|
|
6
|
+
import type { PendingEntry, ChannelContextBuilder, Clock, ConnectionsText, FetchedFile, InboundFile, KnownMember, Integrations, MessageFiles, MessageText, NoteFactory, RouterLimits, Surface, UserLimits } from "@primusclaw/personal-agent";
|
|
7
|
+
/**
|
|
8
|
+
* The router's reading of quotes, links and unreadable files (Python `activity.quote_block`, `with_links`, `with_quote`), on
|
|
9
|
+
* the surface people know as `channelName` (what an unreadable file's line says did not give it).
|
|
10
|
+
*/
|
|
11
|
+
export declare function messageTextFor(channelName: string): MessageText;
|
|
12
|
+
/** PA_USER_* (or the older TEAMS_USER_*): messages per window, tasks at once (Python `limits.UserLimits` and `MessageRateLimiter`). */
|
|
13
|
+
export declare function routerLimits(limits: UserLimits, clock: Clock): RouterLimits;
|
|
14
|
+
/** Python `understanding.channel_context` as `Agent._understood` builds it (the people named, the chat's actions). */
|
|
15
|
+
export declare function channelContextBuilder(store: ContextStore,
|
|
16
|
+
/** What waits for the person's answer (the review service's held confirmations; none without it). */
|
|
17
|
+
pending?: (userId: string) => readonly PendingEntry[]): ChannelContextBuilder;
|
|
18
|
+
interface ContextStore {
|
|
19
|
+
readonly members: {
|
|
20
|
+
knownMembers(): readonly KnownMember[];
|
|
21
|
+
userForChannelId(channelUserId: string): string | null;
|
|
22
|
+
};
|
|
23
|
+
readonly links: {
|
|
24
|
+
clawUserIdOf(userId: string): string | null;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** The note card a settled click ends as (Python `render.note_card`). */
|
|
28
|
+
export declare const noteFactory: NoteFactory;
|
|
29
|
+
/** `/whoami`'s lines after its first (the review service's `connectionsText`, with the deployment's integration lines). */
|
|
30
|
+
export declare function whoamiConnections(integrations: Integrations): ConnectionsText;
|
|
31
|
+
/** A message's files through the surface, each once (Python `FileFetcher.fetch_all`): fetched, and why not for the rest. */
|
|
32
|
+
export declare function fetchAll(surface: Pick<Surface, "fetchFile">, files: readonly InboundFile[]): Promise<{
|
|
33
|
+
fetched: FetchedFile[];
|
|
34
|
+
failed: [string, string][];
|
|
35
|
+
}>;
|
|
36
|
+
/** The assistant's side of a message's files (W5 `MessageFiles`). */
|
|
37
|
+
export declare function messageFiles(surface: Pick<Surface, "fetchFile">): MessageFiles;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The turns the router starts (W4b's turn engine), the Stop cards of turns a phone starts, and the approval and question cards
|
|
3
|
+
* those turns show (`Agent._start_turn`'s `on_approval*`, `Agent._decide`).
|
|
4
|
+
*/
|
|
5
|
+
import type { ClickHandler, Guardrails, Integrations, PublicErrors, TurnRunner } from "@primusclaw/personal-agent";
|
|
6
|
+
import { turn } from "@primusclaw/personal-agent";
|
|
7
|
+
import type { AssemblyBase, ReplyStyle, RouterHooks } from "./features-base.js";
|
|
8
|
+
export interface TurnInputs {
|
|
9
|
+
readonly style: ReplyStyle;
|
|
10
|
+
readonly errors: PublicErrors;
|
|
11
|
+
readonly integrations: Integrations;
|
|
12
|
+
}
|
|
13
|
+
/** The router's turn runner: one engine per run, its approval records bound to the person the turn is for. */
|
|
14
|
+
export declare function turnRunner(base: AssemblyBase, inputs: TurnInputs): TurnRunner;
|
|
15
|
+
/** The Stop cards of turns a phone starts (`StopButtons`). */
|
|
16
|
+
export declare function stopCards(base: AssemblyBase): turn.StopButtons;
|
|
17
|
+
/** The buttons of approval and question cards (`Agent._decide`), the person's allowance taken per approval given. */
|
|
18
|
+
export declare function approvalClicks(base: AssemblyBase, guard: Guardrails, hooks: RouterHooks): ClickHandler;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JsonObject, OutMessage } from "@primusclaw/personal-agent";
|
|
2
|
+
import { DailyBrief, FeedbackFlow, FeedbackService, FeedbackThumbs, GroupContext, Observer } from "@primusclaw/personal-agent";
|
|
3
|
+
import type { AssemblyBase } from "./features-base.js";
|
|
4
|
+
/** The brief Claw put together, as a message (Python `render.brief_markdown`). */
|
|
5
|
+
export declare function briefMarkdown(brief: JsonObject): string;
|
|
6
|
+
export interface W8Parts {
|
|
7
|
+
readonly service: FeedbackService;
|
|
8
|
+
readonly flow: FeedbackFlow;
|
|
9
|
+
readonly thumbs: FeedbackThumbs;
|
|
10
|
+
readonly observer: Observer;
|
|
11
|
+
/** The recent messages of group chats, in memory, as background for an @mention. */
|
|
12
|
+
readonly groupContext: GroupContext;
|
|
13
|
+
readonly brief: DailyBrief;
|
|
14
|
+
/** The Report a problem card under a message of the person's that went wrong. */
|
|
15
|
+
reportView(userId: string, scope: string): OutMessage;
|
|
16
|
+
}
|
|
17
|
+
export declare function w8Parts(base: AssemblyBase, options: {
|
|
18
|
+
readonly briefEnabled: boolean;
|
|
19
|
+
readonly assistantOn: (userId: string) => boolean;
|
|
20
|
+
}): W8Parts;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The features behind the router, built and wired as the Python worker's `main.build_agent`, `Agent.__init__` and
|
|
3
|
+
* `main.build_worker_app` wire them: the router with every feature it hands messages to, what carries Claw's events into the
|
|
4
|
+
* chat (`/claw-events`), the background loops of `main.run`, what runs once at start, and what the release gate's test entry
|
|
5
|
+
* reads. The review service (PA_GITHUB_REVIEW_ENABLED) is built in `features-review.ts`.
|
|
6
|
+
*/
|
|
7
|
+
import type { GroupContext, JsonObject, GithubReview } from "@primusclaw/personal-agent";
|
|
8
|
+
import { Router } from "@primusclaw/personal-agent";
|
|
9
|
+
import type { AssemblyBase } from "./features-base.js";
|
|
10
|
+
export type { AssemblyBase, ReplyStyle, SurfaceShape } from "./features-base.js";
|
|
11
|
+
/** The background loops' period (Python `main.SWEEP_SECONDS`). */
|
|
12
|
+
export declare const SWEEP_MS = 60000;
|
|
13
|
+
/** Claw's event type that asks the chat to carry out a command (Python `claw.ASSISTANT_ACTION`). */
|
|
14
|
+
export declare const ASSISTANT_ACTION = "assistant.action";
|
|
15
|
+
/** The person's notification subscription, as the assistant feature keeps it (what a surface's test entry reads). */
|
|
16
|
+
export interface GateSubscriptions {
|
|
17
|
+
ensure(userId: string): Promise<void>;
|
|
18
|
+
remove(userId: string): Promise<void>;
|
|
19
|
+
/** Whether the subscription carries the assistant's event types. */
|
|
20
|
+
hasAssistantTypes(userId: string): boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface FeatureTimer {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly everyMs: number;
|
|
25
|
+
readonly runAtStart: boolean;
|
|
26
|
+
run(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export interface Features {
|
|
29
|
+
readonly router: Router;
|
|
30
|
+
/** `/claw-events`: an `assistant.action` is carried out as the person (`Agent.run_action`), anything else is shown. */
|
|
31
|
+
readonly deliverEvent: (userId: string, reference: JsonObject, event: JsonObject) => Promise<string>;
|
|
32
|
+
/** The loops of `main.run`: name, period, whether the first run is at start, one run. */
|
|
33
|
+
readonly timers: readonly FeatureTimer[];
|
|
34
|
+
/** Once the worker runs: chats attached to a remote agent are followed again (`Agent.resume_remote`). */
|
|
35
|
+
start(): Promise<void>;
|
|
36
|
+
/** The worker stops: the assistant's open receipts are dropped, so their close timers do not keep the process up. */
|
|
37
|
+
stop(): void;
|
|
38
|
+
/** The review service (PA_GITHUB_REVIEW_ENABLED; undefined off), for the gate's review scenarios and the tests. */
|
|
39
|
+
readonly review: GithubReview | undefined;
|
|
40
|
+
/** The recent messages of group chats (kept in memory): the inbound handler drops a chat the bot was removed from. */
|
|
41
|
+
readonly groupContext: GroupContext;
|
|
42
|
+
/** What the release gate's test entry reads: the subscriptions, and the Claw sessions this worker made. */
|
|
43
|
+
readonly gate: {
|
|
44
|
+
readonly subscriptions: GateSubscriptions | undefined;
|
|
45
|
+
readonly madeSessions: () => readonly string[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** The route the Python worker serves for PA_ON_BEHALF_USERS (link_api.py); a deployment's plugin adds it here. */
|
|
49
|
+
export declare const ON_BEHALF_PATH = "/primus-claw-agent/on-behalf";
|
|
50
|
+
export declare function buildFeatures(given: AssemblyBase): Features;
|