@primusclaw/personal-agent-teams 0.7.2 → 0.8.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/dist/index.js +3482 -5017
- package/dist/main.js +6431 -7969
- package/dist/types/assembly/outbound.d.ts +2 -3
- package/dist/types/assembly/secrets.d.ts +1 -1
- package/dist/types/assembly/worker.d.ts +24 -12
- package/dist/types/caps.d.ts +5 -1
- package/dist/types/gate/routes.d.ts +2 -7
- package/dist/types/index.d.ts +5 -4
- package/dist/types/main.d.ts +1 -1
- package/dist/types/messenger/conversation.d.ts +6 -1
- package/dist/types/observability/build-info.d.ts +1 -5
- package/package.json +4 -4
- package/dist/types/assembly/features-assistant.d.ts +0 -51
- package/dist/types/assembly/features-base.d.ts +0 -51
- package/dist/types/assembly/features-proactive.d.ts +0 -28
- package/dist/types/assembly/features-remote.d.ts +0 -13
- package/dist/types/assembly/features-review.d.ts +0 -31
- package/dist/types/assembly/features-switches.d.ts +0 -26
- package/dist/types/assembly/features-text.d.ts +0 -35
- package/dist/types/assembly/features-turns.d.ts +0 -19
- package/dist/types/assembly/features-w8.d.ts +0 -20
- package/dist/types/assembly/features.d.ts +0 -44
- package/dist/types/assembly/http.d.ts +0 -23
- package/dist/types/assembly/plugins.d.ts +0 -20
- package/dist/types/assembly/runner.d.ts +0 -28
- package/dist/types/assembly/timers.d.ts +0 -14
- package/dist/types/assembly/worker-services.d.ts +0 -23
- package/dist/types/worker-api.d.ts +0 -69
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Clock, Logger } from "@primusclaw/personal-agent";
|
|
2
|
+
import { StartupError } from "@primusclaw/personal-agent-runtime/worker";
|
|
2
3
|
import { FederatedCredential } from "../azure/workload-identity.js";
|
|
3
4
|
import type { TeamsSettings } from "../config/env.js";
|
|
4
5
|
import { type ServiceUrlPolicy } from "../connector/hosts.js";
|
|
@@ -15,9 +16,7 @@ export interface AssemblyDeps {
|
|
|
15
16
|
/** Reads a key file (default: the file system). */
|
|
16
17
|
readonly readFile?: (path: string) => Buffer;
|
|
17
18
|
}
|
|
18
|
-
export
|
|
19
|
-
name: string;
|
|
20
|
-
}
|
|
19
|
+
export { StartupError };
|
|
21
20
|
/** The bot's token in direct mode (BOT_TOKEN_SOURCE). A federated key that cannot be read stops the worker here, at start. */
|
|
22
21
|
export declare function botTokenSource(settings: TeamsSettings, deps: AssemblyDeps): TokenSource;
|
|
23
22
|
/** The worker identity's credential (one for both queues and the vault), when the settings name the identity. */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* worker's own identity. Read once at start; one that cannot be read stops the worker before it opens the store.
|
|
4
4
|
*/
|
|
5
5
|
import type { Clock, Logger, SecretName } from "@primusclaw/personal-agent";
|
|
6
|
-
import type { WorkerEnv } from "
|
|
6
|
+
import type { WorkerEnv } from "@primusclaw/personal-agent-runtime/worker";
|
|
7
7
|
export declare function loadSecrets(env: WorkerEnv, deps: {
|
|
8
8
|
readonly clock: Clock;
|
|
9
9
|
readonly logger: Logger;
|
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The worker
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The worker on Teams (`BuildWorker`): runtime's worker assembly with the Teams surface. What is Teams' own is here:
|
|
3
|
+
* its settings (OUTBOUND_MODE, BOT_*, SERVICEBUS_*, the reply style), secrets from Azure Key Vault, how it reaches Teams
|
|
4
|
+
* (the outbound queue or the Bot Connector), its `TeamsSurface` with the Adaptive Card renderers, the inbound queue's
|
|
5
|
+
* consumer, and the release gate's test entry (its routes on the loopback instead of the queue).
|
|
5
6
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import type
|
|
7
|
+
import { type ConversationRef, type JsonObject, type Logger } from "@primusclaw/personal-agent";
|
|
8
|
+
import { type BuildWorker, type OpenedSurface, type ReplyStyle, type SurfaceAdapter, type SurfaceShape } from "@primusclaw/personal-agent-runtime/worker";
|
|
9
|
+
import { type TeamsSettings } from "../config/env.js";
|
|
10
|
+
import { type Style } from "../config/style.js";
|
|
11
|
+
/** The Teams style's reading of a conversation kind (`style.streams_in`'s conversation types). */
|
|
12
|
+
export declare function conversationTypeOf(kind: string): string;
|
|
13
|
+
/** The switches of the Teams reply style the features read. */
|
|
14
|
+
export declare function replyStyle(style: Style): ReplyStyle;
|
|
15
|
+
/** A stored reference as the surface posts to it; one that names no conversation still gets one (its send then fails). */
|
|
16
|
+
export declare function refOf(reference: JsonObject): ConversationRef;
|
|
17
|
+
/** The Teams fields a followed review keeps to open the reviewer's chat again (Python: service_url, tenant, bot_id). */
|
|
18
|
+
export declare function followWire(asked: ConversationRef): Readonly<Record<string, string>>;
|
|
19
|
+
/** What the features read of Teams besides its port. */
|
|
20
|
+
export declare function teamsShape(teams: Pick<TeamsSettings, "style" | "installHintUrl">): SurfaceShape;
|
|
9
21
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
22
|
+
* `text` as the activity Teams would have sent for the person's own message `messageId` in a stored conversation, read as
|
|
23
|
+
* core's event (what a plugin's `handleAsTyped` hands the router); undefined when it cannot be read.
|
|
12
24
|
*/
|
|
13
|
-
export declare function
|
|
25
|
+
export declare function teamsTypedEvent(logger: Logger): OpenedSurface["typedEvent"];
|
|
14
26
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
27
|
+
* The Teams surface: the release gate's test entry is read first (TEAMS_GATE_ENTRY), the secrets come from where
|
|
28
|
+
* SECRETS_SOURCE says (the environment or Azure Key Vault), and the Teams settings are read after core's.
|
|
17
29
|
*/
|
|
18
|
-
export declare function
|
|
30
|
+
export declare function teamsSurface(): SurfaceAdapter;
|
|
19
31
|
export declare const buildWorker: BuildWorker;
|
package/dist/types/caps.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type { SurfaceCaps } from "@primusclaw/personal-agent";
|
|
1
|
+
import type { SurfaceCaps, SurfaceIdentity, SurfaceLimits } from "@primusclaw/personal-agent";
|
|
2
|
+
/** Teams as core names it, keys by it and says it. */
|
|
3
|
+
export declare const TEAMS_IDENTITY: SurfaceIdentity;
|
|
4
|
+
/** What Teams shows of a message's decorations, and how long it keeps a stream open. */
|
|
5
|
+
export declare const TEAMS_LIMITS: SurfaceLimits;
|
|
2
6
|
/**
|
|
3
7
|
* How the worker reaches Teams (OUTBOUND_MODE): `direct` posts to the Bot Connector itself; `queue` hands envelopes to
|
|
4
8
|
* the outbound queue, which a relay Function posts (send, reply and update only, and the new message's id comes back
|
|
@@ -8,14 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { LinkRepository, Logger, MemberDirectoryRepository, NotifySubscriptionRepository, SessionRepository, TokenExchange } from "@primusclaw/personal-agent";
|
|
10
10
|
import { type HttpRoute } from "@primusclaw/personal-agent-runtime";
|
|
11
|
+
import type { GateSubscriptions } from "@primusclaw/personal-agent-runtime/worker";
|
|
11
12
|
import type { JsonObject } from "../cards/json.js";
|
|
12
|
-
|
|
13
|
-
export interface GateSubscriptions {
|
|
14
|
-
ensure(userId: string): Promise<void>;
|
|
15
|
-
remove(userId: string): Promise<void>;
|
|
16
|
-
/** Whether the subscription carries the assistant's event types. */
|
|
17
|
-
hasAssistantTypes(userId: string): boolean;
|
|
18
|
-
}
|
|
13
|
+
export type { GateSubscriptions };
|
|
19
14
|
export interface GateEntryDeps {
|
|
20
15
|
/** What the inbound queue's consumer hands an activity to. */
|
|
21
16
|
readonly handle: (activity: JsonObject) => Promise<void>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @primusclaw/personal-agent-teams: the personal agent on Microsoft Teams. It implements core's Surface for Teams and
|
|
3
|
-
*
|
|
2
|
+
* @primusclaw/personal-agent-teams: the personal agent on Microsoft Teams. It implements core's Surface for Teams and runs
|
|
3
|
+
* runtime's worker process on it (`teamsSurface`, `buildWorker`, `main`); it depends on core, on the runtime's public
|
|
4
|
+
* interface and on runtime's worker (`@primusclaw/personal-agent-runtime/worker`), never on another surface package.
|
|
4
5
|
*/
|
|
5
6
|
export * from "./caps.js";
|
|
6
7
|
export * from "./activity/reference.js";
|
|
@@ -10,6 +11,6 @@ export * from "./cards/view-buttons.js";
|
|
|
10
11
|
export type { CardElement, Json, JsonObject as CardJson } from "./cards/json.js";
|
|
11
12
|
export * from "./surface.js";
|
|
12
13
|
export * from "./views/index.js";
|
|
13
|
-
export
|
|
14
|
-
export { buildWorker } from "./assembly/worker.js";
|
|
14
|
+
export type { BuildWorker, PluginFactory, Worker, WorkerEnv, WorkerOptions, WorkerServices, } from "@primusclaw/personal-agent-runtime/worker";
|
|
15
|
+
export { buildWorker, teamsSurface } from "./assembly/worker.js";
|
|
15
16
|
export { main } from "./main.js";
|
package/dist/types/main.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* before it takes a message: status 2 for a secret that cannot be read, 1 for anything else (a setting that cannot work).
|
|
5
5
|
*/
|
|
6
6
|
import { type Plugins } from "@primusclaw/personal-agent";
|
|
7
|
-
import type
|
|
7
|
+
import { type PluginFactory, type WorkerEnv } from "@primusclaw/personal-agent-runtime/worker";
|
|
8
8
|
/**
|
|
9
9
|
* Build and run a worker with `plugins` (a deployment's own entry passes its plugins or its factory; the public program the
|
|
10
10
|
* neutral ones); the exit status the process should end with. Every entry ends the same way: one CRITICAL line, 2 for a
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* leaves one log line (what, to which conversation, how long, whether an ack is awaited; never the text): after a turn
|
|
5
5
|
* it is the only trace of what the worker handed to Teams. In a group chat everything posted is masked first.
|
|
6
6
|
*/
|
|
7
|
-
import type { Clock, Conversation, ConversationRef, DeleteUnsupported, Envelope, LiveStream, Logger, MessageId, OutMessage, Random, Result, StreamRefused, UpdateOptions } from "@primusclaw/personal-agent";
|
|
7
|
+
import type { Clock, Conversation, ConversationRef, DeleteUnsupported, Envelope, LiveStream, Logger, MessageId, OutMessage, Random, Result, StreamRefused, SurfaceCaps, UpdateOptions } from "@primusclaw/personal-agent";
|
|
8
8
|
import { type Outbox } from "../outbound/outbox.js";
|
|
9
9
|
import { type StreamContext } from "../stream/live-stream.js";
|
|
10
10
|
import type { AckRegistry } from "./acks.js";
|
|
@@ -19,6 +19,8 @@ export declare const ACK_TIMEOUT_MS = 60000;
|
|
|
19
19
|
export declare const SLOW_PUBLISH_MS = 1000;
|
|
20
20
|
export interface ConversationParts {
|
|
21
21
|
readonly ref: ConversationRef;
|
|
22
|
+
/** The caps of the surface this conversation is on. */
|
|
23
|
+
readonly caps: SurfaceCaps;
|
|
22
24
|
readonly outbox: Outbox;
|
|
23
25
|
readonly acks: AckRegistry;
|
|
24
26
|
readonly clock: Clock;
|
|
@@ -36,6 +38,9 @@ export declare class TeamsConversation implements Conversation {
|
|
|
36
38
|
/** A message the bot removed or replaced elsewhere is settled: an unsettled click on it then leaves it alone. */
|
|
37
39
|
markSettled(id: MessageId): void;
|
|
38
40
|
get ref(): ConversationRef;
|
|
41
|
+
get caps(): SurfaceCaps;
|
|
42
|
+
/** The activity the reference was read from (`activityId` of the stored reference), which a stream replies under. */
|
|
43
|
+
get replyTo(): MessageId;
|
|
39
44
|
private get masker();
|
|
40
45
|
/** The activity as it is posted here: masked in a group chat. */
|
|
41
46
|
private prepare;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
/** The metric's lines (HELP, TYPE and the sample), each ending in a newline. */
|
|
3
|
-
export declare function buildInfoText(version: string, node: string): string;
|
|
1
|
+
export { BUILD_INFO_METRIC, buildInfoText, withBuildInfo } from "@primusclaw/personal-agent-runtime/worker";
|
|
4
2
|
/** The teams package's version, read from its package.json (in the sources and in the published package alike). */
|
|
5
3
|
export declare function teamsVersion(): string;
|
|
6
|
-
/** `render`'s text with the build info appended (after a newline, if the text lacks its last one). */
|
|
7
|
-
export declare function withBuildInfo(render: () => string, info: string): () => string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primusclaw/personal-agent-teams",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The personal agent on Microsoft Teams: activities, Adaptive Cards, streams, Bot Connector, inbound queue,
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "The personal agent on Microsoft Teams: activities, Adaptive Cards, streams, Bot Connector, inbound queue, and the worker's Teams surface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@azure/core-auth": "^1.11.0",
|
|
37
37
|
"@azure/service-bus": "^7.10.0",
|
|
38
|
-
"@primusclaw/personal-agent": "0.
|
|
39
|
-
"@primusclaw/personal-agent-runtime": "0.
|
|
38
|
+
"@primusclaw/personal-agent": "0.8.0",
|
|
39
|
+
"@primusclaw/personal-agent-runtime": "0.8.0",
|
|
40
40
|
"zod": "^4.6.7"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -1,51 +0,0 @@
|
|
|
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 { Style } from "../config/style.js";
|
|
9
|
-
import type { AssemblyBase, RouterHooks } from "./features-base.js";
|
|
10
|
-
/** The router's test of a command typed whole (`understanding.exact_command`). */
|
|
11
|
-
export declare const isExactCommand: (text: string) => boolean;
|
|
12
|
-
export interface AssistantParts {
|
|
13
|
-
/** undefined: notifications are off (no NOTIFY_WEBHOOK_URL). */
|
|
14
|
-
readonly subs: SubscriptionKeeper | undefined;
|
|
15
|
-
readonly chat: AssistantChatService;
|
|
16
|
-
readonly board: Board;
|
|
17
|
-
readonly receipts: Receipts;
|
|
18
|
-
readonly directChat: DirectChat;
|
|
19
|
-
readonly actions: AssistantActions;
|
|
20
|
-
readonly clicks: readonly ClickHandler[];
|
|
21
|
-
}
|
|
22
|
-
/** The approval card of a request an agent on the person's machine waits on (W6b's view). */
|
|
23
|
-
export declare function remoteAskCard(request: Parameters<ConstructorParameters<typeof Board>[0]["remoteAsk"]>[0]): {
|
|
24
|
-
body: {
|
|
25
|
-
type: "view";
|
|
26
|
-
view: {
|
|
27
|
-
name: "terminalAsk";
|
|
28
|
-
model: remoteView.TerminalAskView;
|
|
29
|
-
};
|
|
30
|
-
fallbackText: string;
|
|
31
|
-
};
|
|
32
|
-
} | {
|
|
33
|
-
body: {
|
|
34
|
-
type: "view";
|
|
35
|
-
view: {
|
|
36
|
-
name: "remoteAsk";
|
|
37
|
-
model: remoteView.RemoteAskView;
|
|
38
|
-
};
|
|
39
|
-
fallbackText: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
export interface AssistantInputs {
|
|
43
|
-
readonly style: Style;
|
|
44
|
-
readonly integrations: Integrations;
|
|
45
|
-
/** A review the assistant handed back (`review_for_other`): to the review service, "dropped" without it. */
|
|
46
|
-
readonly reviewHandoff: (userId: string, event: Readonly<Record<string, unknown>>) => "delivered" | "dropped";
|
|
47
|
-
/** NOTIFY_WEBHOOK_URL ("" off). */
|
|
48
|
-
readonly notifyUrl: string;
|
|
49
|
-
readonly hooks: RouterHooks;
|
|
50
|
-
}
|
|
51
|
-
export declare function assistantParts(base: AssemblyBase, inputs: AssistantInputs): AssistantParts;
|
|
@@ -1,51 +0,0 @@
|
|
|
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, InboundMessage, 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
|
-
import type { TeamsSettings } from "../config/env.js";
|
|
8
|
-
export interface AssemblyBase {
|
|
9
|
-
/** Core's settings (`readSettings`). */
|
|
10
|
-
readonly settings: Settings;
|
|
11
|
-
readonly teams: TeamsSettings;
|
|
12
|
-
readonly store: SqliteStore;
|
|
13
|
-
readonly claw: ClawPort;
|
|
14
|
-
/** The channel (the worker's `TeamsSurface`; a test's fake surface). */
|
|
15
|
-
readonly surface: Surface;
|
|
16
|
-
readonly clock: Clock;
|
|
17
|
-
readonly random: Random;
|
|
18
|
-
readonly logger: Logger;
|
|
19
|
-
/** What the platform and GitHub clients send with (the global `fetch`; a test's fake). */
|
|
20
|
-
readonly fetch: typeof fetch;
|
|
21
|
-
readonly metrics: MetricsPort;
|
|
22
|
-
readonly securityLog: SecurityLog;
|
|
23
|
-
/** The one request scope (runtime `alsRequestScope`): the router enters it per inbound event, everything else reads it. */
|
|
24
|
-
readonly requestScope: RequestScope;
|
|
25
|
-
/** The last log lines of each chat, for a report's scene (Python `feedback.LogBuffer`). */
|
|
26
|
-
readonly chatLog: ChatLog;
|
|
27
|
-
readonly plugins: Plugins;
|
|
28
|
-
readonly exchange: TokenExchange;
|
|
29
|
-
/** The switches the Python worker's `main.py` read from the environment itself (`features-switches.ts`). */
|
|
30
|
-
readonly env: Readonly<Record<string, string | undefined>>;
|
|
31
|
-
}
|
|
32
|
-
/** What the features ask of the router, bound once it is built (a call before then is a defect of the assembly). */
|
|
33
|
-
export interface RouterHooks {
|
|
34
|
-
/** A chat turn of the old kind is running in the person's 1:1 chat (`Router.hasPersonalTurn`). */
|
|
35
|
-
legacyTurn(userId: string): boolean;
|
|
36
|
-
/** A work item was stopped from its card: whatever follows it here ends as stopped (`Agent._item_stopped`). */
|
|
37
|
-
itemStopped(itemId: string): void;
|
|
38
|
-
/** The person pressed Deny on an approval of the chat's running turn (`turn.tool_denied`). */
|
|
39
|
-
toolDenied(userId: string, scope: string): void;
|
|
40
|
-
/** `text` carried out exactly as typed, with `key`, in `conversation` (`Agent._command`). */
|
|
41
|
-
runCommand(text: string, sender: SenderOf, conversation: ConversationOf, key: string): Promise<boolean>;
|
|
42
|
-
/** What reads Claw for a person with nobody to ask (`Agent._background_credential`); undefined: none. */
|
|
43
|
-
background(userId: string): Promise<string | undefined>;
|
|
44
|
-
/** `message` handled as one the person typed (`Router.handle`): what a choice card's Send sends. */
|
|
45
|
-
typed(message: InboundMessage): Promise<void>;
|
|
46
|
-
}
|
|
47
|
-
type SenderOf = Parameters<import("@primusclaw/personal-agent").Router["chat"]>[0];
|
|
48
|
-
type ConversationOf = Parameters<import("@primusclaw/personal-agent").Router["chat"]>[1];
|
|
49
|
-
/** The Teams style's reading of a conversation kind (`style.streams_in`'s conversation types). */
|
|
50
|
-
export declare function conversationTypeOf(kind: string): string;
|
|
51
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
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, ConversationRef, FollowReach, JsonObject, ProactiveHold, PublicErrors, Router } from "@primusclaw/personal-agent";
|
|
7
|
-
import { Proactive, Release } from "@primusclaw/personal-agent";
|
|
8
|
-
import type { Style } from "../config/style.js";
|
|
9
|
-
import type { AssistantParts } from "./features-assistant.js";
|
|
10
|
-
import type { AssemblyBase } from "./features-base.js";
|
|
11
|
-
/** A stored reference as the surface posts to it; one that names no conversation still gets one (its send then fails). */
|
|
12
|
-
export declare function refOf(reference: JsonObject): ConversationRef;
|
|
13
|
-
export declare function conversationFor(base: Pick<AssemblyBase, "surface">): (reference: JsonObject) => Conversation;
|
|
14
|
-
export interface ProactiveParts {
|
|
15
|
-
readonly proactive: Proactive;
|
|
16
|
-
readonly release: Release;
|
|
17
|
-
}
|
|
18
|
-
export declare function proactiveParts(base: AssemblyBase, style: Style, assistant: Pick<AssistantParts, "receipts" | "directChat">, errors: PublicErrors, router?: () => Router): ProactiveParts;
|
|
19
|
-
/** The event claim key prefix of a turn whose identity card was sent (`identityAfterRefusal`). */
|
|
20
|
-
export declare const IDENTITY_REFUSED_PREFIX = "identity-refused:";
|
|
21
|
-
/** What the router reads of quiet hours and /pause (`muted` as a word or null, `release` on /resume). */
|
|
22
|
-
export declare function proactiveHold(parts: ProactiveParts): ProactiveHold;
|
|
23
|
-
/**
|
|
24
|
-
* What the remote agents' follower reads of it. Python's follower hands Proactive its chat key as the person (`self.aad_id`
|
|
25
|
-
* 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
|
|
26
|
-
* unchanged; the event id of a held message is a fresh uuid4 hex, as Python's `hold_remote` makes it.
|
|
27
|
-
*/
|
|
28
|
-
export declare function followReach(parts: ProactiveParts, base: Pick<AssemblyBase, "random">): FollowReach;
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The review delegation (TEAMS_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 (TEAMS_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 TEAMS_GITHUB_REVIEW_ENABLED off. */
|
|
31
|
-
export declare function reviewParts(base: AssemblyBase, inputs: ReviewInputs, assistant: Pick<AssistantParts, "receipts" | "chat">): ReviewParts | undefined;
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The router's small readers, built from core's pure functions: what a message carries besides its words (quotes, links,
|
|
3
|
-
* files Teams 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
|
-
/** The router's reading of quotes, links and unreadable files (Python `activity.quote_block`, `with_links`, `with_quote`). */
|
|
8
|
-
export declare const messageText: MessageText;
|
|
9
|
-
/** TEAMS_USER_*: messages per window, tasks at once (Python `limits.UserLimits` and `MessageRateLimiter`). */
|
|
10
|
-
export declare function routerLimits(limits: UserLimits, clock: Clock): RouterLimits;
|
|
11
|
-
/** Python `understanding.channel_context` as `Agent._understood` builds it (the people named, the chat's actions). */
|
|
12
|
-
export declare function channelContextBuilder(store: ContextStore,
|
|
13
|
-
/** What waits for the person's answer (the review service's held confirmations; none without it). */
|
|
14
|
-
pending?: (userId: string) => readonly PendingEntry[]): ChannelContextBuilder;
|
|
15
|
-
interface ContextStore {
|
|
16
|
-
readonly members: {
|
|
17
|
-
knownMembers(): readonly KnownMember[];
|
|
18
|
-
userForChannelId(channelUserId: string): string | null;
|
|
19
|
-
};
|
|
20
|
-
readonly links: {
|
|
21
|
-
clawUserIdOf(userId: string): string | null;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/** The note card a settled click ends as (Python `render.note_card`). */
|
|
25
|
-
export declare const noteFactory: NoteFactory;
|
|
26
|
-
/** `/whoami`'s lines after its first (the review service's `connectionsText`, with the deployment's integration lines). */
|
|
27
|
-
export declare function whoamiConnections(integrations: Integrations): ConnectionsText;
|
|
28
|
-
/** A message's files through the surface, each once (Python `FileFetcher.fetch_all`): fetched, and why not for the rest. */
|
|
29
|
-
export declare function fetchAll(surface: Pick<Surface, "fetchFile">, files: readonly InboundFile[]): Promise<{
|
|
30
|
-
fetched: FetchedFile[];
|
|
31
|
-
failed: [string, string][];
|
|
32
|
-
}>;
|
|
33
|
-
/** The assistant's side of a message's files (W5 `MessageFiles`). */
|
|
34
|
-
export declare function messageFiles(surface: Pick<Surface, "fetchFile">): MessageFiles;
|
|
35
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
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 Style } from "../config/style.js";
|
|
8
|
-
import type { AssemblyBase, RouterHooks } from "./features-base.js";
|
|
9
|
-
export interface TurnInputs {
|
|
10
|
-
readonly style: Style;
|
|
11
|
-
readonly errors: PublicErrors;
|
|
12
|
-
readonly integrations: Integrations;
|
|
13
|
-
}
|
|
14
|
-
/** The router's turn runner: one engine per run, its approval records bound to the person the turn is for. */
|
|
15
|
-
export declare function turnRunner(base: AssemblyBase, inputs: TurnInputs): TurnRunner;
|
|
16
|
-
/** The Stop cards of turns a phone starts (`StopButtons`). */
|
|
17
|
-
export declare function stopCards(base: AssemblyBase): turn.StopButtons;
|
|
18
|
-
/** The buttons of approval and question cards (`Agent._decide`), the person's allowance taken per approval given. */
|
|
19
|
-
export declare function approvalClicks(base: AssemblyBase, guard: Guardrails, hooks: RouterHooks): ClickHandler;
|
|
@@ -1,20 +0,0 @@
|
|
|
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;
|
|
@@ -1,44 +0,0 @@
|
|
|
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 (TEAMS_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 { GateSubscriptions } from "../gate/routes.js";
|
|
10
|
-
import type { AssemblyBase } from "./features-base.js";
|
|
11
|
-
export type { AssemblyBase } from "./features-base.js";
|
|
12
|
-
/** The background loops' period (Python `main.SWEEP_SECONDS`). */
|
|
13
|
-
export declare const SWEEP_MS = 60000;
|
|
14
|
-
/** Claw's event type that asks the chat to carry out a command (Python `claw.ASSISTANT_ACTION`). */
|
|
15
|
-
export declare const ASSISTANT_ACTION = "assistant.action";
|
|
16
|
-
export interface FeatureTimer {
|
|
17
|
-
readonly name: string;
|
|
18
|
-
readonly everyMs: number;
|
|
19
|
-
readonly runAtStart: boolean;
|
|
20
|
-
run(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export interface Features {
|
|
23
|
-
readonly router: Router;
|
|
24
|
-
/** `/claw-events`: an `assistant.action` is carried out as the person (`Agent.run_action`), anything else is shown. */
|
|
25
|
-
readonly deliverEvent: (userId: string, reference: JsonObject, event: JsonObject) => Promise<string>;
|
|
26
|
-
/** The loops of `main.run`: name, period, whether the first run is at start, one run. */
|
|
27
|
-
readonly timers: readonly FeatureTimer[];
|
|
28
|
-
/** Once the worker runs: chats attached to a remote agent are followed again (`Agent.resume_remote`). */
|
|
29
|
-
start(): Promise<void>;
|
|
30
|
-
/** The worker stops: the assistant's open receipts are dropped, so their close timers do not keep the process up. */
|
|
31
|
-
stop(): void;
|
|
32
|
-
/** The review service (TEAMS_GITHUB_REVIEW_ENABLED; undefined off), for the gate's review scenarios and the tests. */
|
|
33
|
-
readonly review: GithubReview | undefined;
|
|
34
|
-
/** The recent messages of group chats (kept in memory): the inbound handler drops a chat the bot was removed from. */
|
|
35
|
-
readonly groupContext: GroupContext;
|
|
36
|
-
/** What the release gate's test entry reads: the subscriptions, and the Claw sessions this worker made. */
|
|
37
|
-
readonly gate: {
|
|
38
|
-
readonly subscriptions: GateSubscriptions | undefined;
|
|
39
|
-
readonly madeSessions: () => readonly string[];
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/** The route the Python worker serves for TEAMS_ON_BEHALF_USERS (link_api.py); a deployment's plugin adds it here. */
|
|
43
|
-
export declare const ON_BEHALF_PATH = "/primus-claw-agent/on-behalf";
|
|
44
|
-
export declare function buildFeatures(given: AssemblyBase): Features;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The worker's HTTP endpoints as it runs them (the Python worker's `build_worker_app`): `/healthz`, the console's
|
|
3
|
-
* `/primus-claw-agent/link`, `/claw-events/<route>` when proactive messages are on, the routes a deployment adds, and in the
|
|
4
|
-
* release gate's test entry its `/gate/v1/*`. `/metrics` is served on a port of its own.
|
|
5
|
-
*/
|
|
6
|
-
import type { ClawPort, Clock, JsonObject, Logger, MetricsPort, Plugins } from "@primusclaw/personal-agent";
|
|
7
|
-
import { type HttpRoute, type SqliteStore } from "@primusclaw/personal-agent-runtime";
|
|
8
|
-
export interface WorkerRoutesParts {
|
|
9
|
-
readonly store: SqliteStore;
|
|
10
|
-
readonly claw: ClawPort;
|
|
11
|
-
readonly clock: Clock;
|
|
12
|
-
readonly metrics: MetricsPort;
|
|
13
|
-
readonly logger: Logger;
|
|
14
|
-
readonly plugins: Plugins;
|
|
15
|
-
/** PROACTIVE_ENABLED: Claw's notifications are taken at /claw-events. */
|
|
16
|
-
readonly proactive: boolean;
|
|
17
|
-
/** TEAMS_CLAW_EVENTS_GONE. */
|
|
18
|
-
readonly gone: boolean;
|
|
19
|
-
readonly deliverEvent: (userId: string, reference: JsonObject, event: JsonObject) => Promise<string>;
|
|
20
|
-
}
|
|
21
|
-
export declare function workerRoutes(parts: WorkerRoutesParts): HttpRoute[];
|
|
22
|
-
/** `/metrics` on its own port: the Prometheus text. */
|
|
23
|
-
export declare function metricsRoutes(render: () => string): HttpRoute[];
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The platform services the Python worker always talks to, in place of the neutral plugins a deployment did not replace:
|
|
3
|
-
* whose key it is from SaFE's `/users/self` (the Python `safe.user_id_of` / `safe.whoami`, used by the subscriptions,
|
|
4
|
-
* `/whoami` and a report), and whose exchanged identity token it is from Claw's `/v1/me` (SaFE refuses such a token), a key deleted at SaFE when it is given up (`safe.revoke_own_key`: /unlink, and pending keys
|
|
5
|
-
* nobody redeemed), and the GitHub issues a report is filed as (`FeedbackService`'s GitHub sink, when FEEDBACK_REPO
|
|
6
|
-
* and a credential are set). A plugin a deployment did replace is kept.
|
|
7
|
-
*/
|
|
8
|
-
import { type Logger, type Plugins, type SecretName, type Settings } from "@primusclaw/personal-agent";
|
|
9
|
-
import type { WorkerEnv } from "../worker-api.js";
|
|
10
|
-
export interface PlatformDeps {
|
|
11
|
-
readonly env: WorkerEnv;
|
|
12
|
-
readonly settings: Settings;
|
|
13
|
-
readonly secrets: ReadonlyMap<SecretName, string>;
|
|
14
|
-
readonly fetch: typeof fetch;
|
|
15
|
-
/** Seconds since the epoch. */
|
|
16
|
-
readonly now: () => number;
|
|
17
|
-
readonly logger: Logger;
|
|
18
|
-
}
|
|
19
|
-
/** `plugins` with the identity lookup and the feedback sink the Python worker builds in `main.run` where they are neutral. */
|
|
20
|
-
export declare function platformPlugins(plugins: Plugins, deps: PlatformDeps): Plugins;
|
|
@@ -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>;
|