@primusclaw/personal-agent-teams 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.
@@ -1,28 +0,0 @@
1
- /**
2
- * A built worker's run: its HTTP endpoints and /metrics listening, the features started, the timers running, then the
3
- * inbound consumer (or, with no queue, waiting) until it is stopped; everything closed on the way out.
4
- */
5
- import type { Clock, Logger } from "@primusclaw/personal-agent";
6
- import { type buildServer } from "@primusclaw/personal-agent-runtime";
7
- /** The HTTP server the runtime builds (the teams package does not depend on its framework). */
8
- type Server = ReturnType<typeof buildServer>;
9
- import type { InboundConsumer } from "../servicebus/consumer.js";
10
- import type { Worker } from "../worker-api.js";
11
- import { type Timer } from "./timers.js";
12
- export interface RunnerParts {
13
- readonly app: Server;
14
- readonly metricsApp: Server;
15
- readonly host: string;
16
- readonly port: number;
17
- readonly metricsPort: number;
18
- readonly consumer: InboundConsumer | undefined;
19
- readonly start: () => Promise<void>;
20
- readonly timers: readonly Timer[];
21
- readonly clock: Clock;
22
- readonly logger: Logger;
23
- readonly close: () => Promise<void>;
24
- }
25
- /** Run every close in turn, each even when one before it failed; a failure is logged by its kind. */
26
- export declare function closeAll(logger: Logger, closes: readonly (() => unknown)[]): Promise<void>;
27
- export declare function runner(parts: RunnerParts): Worker;
28
- export {};
@@ -1,14 +0,0 @@
1
- /**
2
- * The worker's background loops (the Python worker's sweep, release, resend, retry and mend tasks): each runs every
3
- * `everyMs` (first at start when `runAtStart`) until the worker stops; a run that fails is logged by its kind and the loop
4
- * goes on.
5
- */
6
- import type { Clock, Logger } from "@primusclaw/personal-agent";
7
- export interface Timer {
8
- readonly name: string;
9
- readonly everyMs: number;
10
- readonly runAtStart: boolean;
11
- run(): Promise<void>;
12
- }
13
- /** Run every timer until `signal` aborts; resolves when all have stopped. */
14
- export declare function startTimers(timers: readonly Timer[], clock: Clock, logger: Logger, signal: AbortSignal): Promise<void>;
@@ -1,23 +0,0 @@
1
- /**
2
- * The worker's services a deployment's plugins are built with (`WorkerServices`): the store's reads, a post into a chat,
3
- * and a message handled as the person's own (the Python worker's `Agent.on_behalf`: `activity_of_reference` with the text,
4
- * handled in a task of its own with provenance "on_behalf"). The router is bound once it is built.
5
- */
6
- import { type Logger, type Router, type SecurityLog, type Surface } from "@primusclaw/personal-agent";
7
- import type { SqliteStore } from "@primusclaw/personal-agent-runtime";
8
- import type { WorkerServices } from "../worker-api.js";
9
- export interface ServicesParts {
10
- readonly store: SqliteStore;
11
- readonly surface: Surface;
12
- readonly securityLog: SecurityLog;
13
- readonly logger: Logger;
14
- readonly botName: string;
15
- }
16
- /** The services, the router they wait for, and the background tasks to wait for when the worker stops. */
17
- export interface BoundServices {
18
- readonly services: WorkerServices;
19
- bind(router: Router): void;
20
- /** Resolves when every task spawned so far has ended. */
21
- idle(): Promise<void>;
22
- }
23
- export declare function workerServices(parts: ServicesParts): BoundServices;
@@ -1,69 +0,0 @@
1
- /**
2
- * The worker process, as an assembly can build it: the public `main` builds it with the neutral plugins, a deployment's
3
- * own `main` (with its identity platform, model gateway rules, extra routes) builds it with its plugins. Everything else
4
- * (store, Claw client, Teams outbound, inbound queue, HTTP endpoints) is assembled from the environment the same way for
5
- * both.
6
- */
7
- import type { Clock, ConversationRef, IntegrationRegistry, Logger, MessageId, Plugins } from "@primusclaw/personal-agent";
8
- /** The environment the worker reads its settings from (`process.env`, or a copy a test or a gate made). */
9
- export type WorkerEnv = Readonly<Record<string, string | undefined>>;
10
- export interface WorkerOptions {
11
- /** Defaults: the system clock, a line logger on stderr, the global `fetch`. */
12
- readonly clock?: Clock;
13
- readonly logger?: Logger;
14
- readonly fetch?: typeof fetch;
15
- /**
16
- * A deployment's own services (its MCP servers, its /whoami lines), registered as the worker is built, on top of
17
- * whatever the plugins' `integrations` already hold. Registering a server again renames it, but cannot clear the
18
- * `query` flag the plugins gave it (the registry only adds). The public worker registers none.
19
- */
20
- readonly registerIntegrations?: (registry: IntegrationRegistry) => void;
21
- }
22
- /** A built worker: nothing runs until `run`. */
23
- export interface Worker {
24
- /**
25
- * Start every part (HTTP endpoints, the inbound consumer or the gate's test entry, the timers) and resolve when the
26
- * worker has stopped: after `stop`, or when a part fails (the promise rejects then).
27
- */
28
- run(): Promise<void>;
29
- /** Stop taking new work, finish what is in hand, close connections. */
30
- stop(): Promise<void>;
31
- }
32
- /**
33
- * What a deployment's plugins may use of the worker they are built for (what the Python worker's on-behalf route used of
34
- * its `Agent`). A person is named by the store's user id: their directory id (Teams: the Entra object id). `post` and the
35
- * store reads work as soon as the plugins are built; `handleAsTyped` and `spawn` work once the worker is assembled (before
36
- * then they throw: a plugin calls them from a request, never while it is built).
37
- */
38
- export interface WorkerServices {
39
- /** The people whose link recorded Claw user `clawUserId`. */
40
- channelUsersOf(clawUserId: string): readonly string[];
41
- /** The Claw user a person's link recorded. */
42
- clawUserOf(userId: string): string | undefined;
43
- /** Whether a person's link holds a key. */
44
- hasKey(userId: string): boolean;
45
- /** Where the bot last talked with a person (their stored conversation reference). */
46
- conversationOf(userId: string): ConversationRef | undefined;
47
- /** The people this worker knows by name. */
48
- knownPeople(): readonly {
49
- readonly name: string;
50
- readonly objectId: string;
51
- }[];
52
- /** Post `text` into `conversation`; the id the channel gave it, or undefined when it did not say it arrived. */
53
- post(conversation: ConversationRef, text: string): Promise<MessageId | undefined>;
54
- /** Handle `text` as the person's own message `messageId` in `conversation`, with provenance "on_behalf". */
55
- handleAsTyped(conversation: ConversationRef, userId: string, messageId: MessageId, text: string): Promise<void>;
56
- /** Run `task` in the background; the worker waits for it when it stops, and logs a failure by its kind. */
57
- spawn(task: () => Promise<void>): void;
58
- /** One `on_behalf_message` security event (operation "on_behalf"); the fields are shape-checked like every event's. */
59
- audit(fields: Readonly<Record<string, string | number | null>>): void;
60
- readonly logger: Logger;
61
- }
62
- /** A deployment's plugins, built with the worker's services; what it leaves out is the neutral default. */
63
- export type PluginFactory = (services: WorkerServices) => Partial<Plugins>;
64
- /**
65
- * Build the worker from `env` with `plugins` (or a factory that builds them with the worker's services). Rejects at start,
66
- * before anything is served, when the settings are not usable (a missing required setting, an unreadable key file): a
67
- * worker that starts must be able to answer.
68
- */
69
- export type BuildWorker = (env: WorkerEnv, plugins: Plugins | PluginFactory, options?: WorkerOptions) => Promise<Worker>;