@primusclaw/personal-agent-teams 0.1.1 → 0.3.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 +302 -68
- package/dist/main.js +302 -68
- package/dist/types/activity/inbound/group-changes.d.ts +12 -0
- package/dist/types/activity/inbound/index.d.ts +1 -0
- package/dist/types/assembly/features-assistant.d.ts +9 -0
- package/dist/types/assembly/features-proactive.d.ts +4 -2
- package/dist/types/assembly/features-w8.d.ts +3 -1
- package/dist/types/assembly/features.d.ts +3 -1
- package/dist/types/assembly/inbound.d.ts +3 -0
- package/dist/types/assembly/plugins.d.ts +1 -1
- package/dist/types/config/env.d.ts +7 -1
- package/dist/types/connector/tokens/client-secret.d.ts +36 -0
- package/dist/types/views/remote/index.d.ts +2 -2
- package/dist/types/views/remote/permission-cards.d.ts +8 -0
- package/package.json +3 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Activity } from "./schema.js";
|
|
2
|
+
/** The part of core's `GroupContext` these activities change. */
|
|
3
|
+
export interface GroupContextChanges {
|
|
4
|
+
forget(chatId: string): void;
|
|
5
|
+
remove(chatId: string, messageId: string): void;
|
|
6
|
+
edit(chatId: string, messageId: string, text: string): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Applies a group chat's removal, delete or edit to `context`. `textOf` reads an edited message's words as a message's
|
|
10
|
+
* are read (undefined: not a message from a person). True when the activity was one of these.
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyGroupChange(raw: unknown, context: GroupContextChanges, textOf: (activity: Activity) => string | undefined): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Reading an inbound Teams activity: its schema, the readers of its parts, and its mapping to core's events. */
|
|
2
2
|
export * from "./actions.js";
|
|
3
|
+
export * from "./group-changes.js";
|
|
3
4
|
export * from "./identity.js";
|
|
4
5
|
export * from "./links.js";
|
|
5
6
|
export * from "./markup.js";
|
|
@@ -21,6 +21,15 @@ export interface AssistantParts {
|
|
|
21
21
|
}
|
|
22
22
|
/** The approval card of a request an agent on the person's machine waits on (W6b's view). */
|
|
23
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
|
+
} | {
|
|
24
33
|
body: {
|
|
25
34
|
type: "view";
|
|
26
35
|
view: {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
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
4
|
* the router and the remote agents read (`ProactiveHold`, `FollowReach`).
|
|
5
5
|
*/
|
|
6
|
-
import type { Conversation, ConversationRef, FollowReach, JsonObject, ProactiveHold, PublicErrors } from "@primusclaw/personal-agent";
|
|
6
|
+
import type { Conversation, ConversationRef, FollowReach, JsonObject, ProactiveHold, PublicErrors, Router } from "@primusclaw/personal-agent";
|
|
7
7
|
import { Proactive, Release } from "@primusclaw/personal-agent";
|
|
8
8
|
import type { Style } from "../config/style.js";
|
|
9
9
|
import type { AssistantParts } from "./features-assistant.js";
|
|
@@ -15,7 +15,9 @@ export interface ProactiveParts {
|
|
|
15
15
|
readonly proactive: Proactive;
|
|
16
16
|
readonly release: Release;
|
|
17
17
|
}
|
|
18
|
-
export declare function proactiveParts(base: AssemblyBase, style: Style, assistant: Pick<AssistantParts, "receipts" | "directChat">, errors: PublicErrors): ProactiveParts;
|
|
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:";
|
|
19
21
|
/** What the router reads of quiet hours and /pause (`muted` as a word or null, `release` on /resume). */
|
|
20
22
|
export declare function proactiveHold(parts: ProactiveParts): ProactiveHold;
|
|
21
23
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JsonObject, OutMessage } from "@primusclaw/personal-agent";
|
|
2
|
-
import { DailyBrief, FeedbackFlow, FeedbackService, FeedbackThumbs, Observer } from "@primusclaw/personal-agent";
|
|
2
|
+
import { DailyBrief, FeedbackFlow, FeedbackService, FeedbackThumbs, GroupContext, Observer } from "@primusclaw/personal-agent";
|
|
3
3
|
import type { AssemblyBase } from "./features-base.js";
|
|
4
4
|
/** The brief Claw put together, as a message (Python `render.brief_markdown`). */
|
|
5
5
|
export declare function briefMarkdown(brief: JsonObject): string;
|
|
@@ -8,6 +8,8 @@ export interface W8Parts {
|
|
|
8
8
|
readonly flow: FeedbackFlow;
|
|
9
9
|
readonly thumbs: FeedbackThumbs;
|
|
10
10
|
readonly observer: Observer;
|
|
11
|
+
/** The recent messages of group chats, in memory, as background for an @mention. */
|
|
12
|
+
readonly groupContext: GroupContext;
|
|
11
13
|
readonly brief: DailyBrief;
|
|
12
14
|
/** The Report a problem card under a message of the person's that went wrong. */
|
|
13
15
|
reportView(userId: string, scope: string): OutMessage;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* chat (`/claw-events`), the background loops of `main.run`, what runs once at start, and what the release gate's test entry
|
|
5
5
|
* reads. The review service (TEAMS_GITHUB_REVIEW_ENABLED) is built in `features-review.ts`.
|
|
6
6
|
*/
|
|
7
|
-
import type { JsonObject, GithubReview } from "@primusclaw/personal-agent";
|
|
7
|
+
import type { GroupContext, JsonObject, GithubReview } from "@primusclaw/personal-agent";
|
|
8
8
|
import { Router } from "@primusclaw/personal-agent";
|
|
9
9
|
import type { GateSubscriptions } from "../gate/routes.js";
|
|
10
10
|
import type { AssemblyBase } from "./features-base.js";
|
|
@@ -31,6 +31,8 @@ export interface Features {
|
|
|
31
31
|
stop(): void;
|
|
32
32
|
/** The review service (TEAMS_GITHUB_REVIEW_ENABLED; undefined off), for the gate's review scenarios and the tests. */
|
|
33
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;
|
|
34
36
|
/** What the release gate's test entry reads: the subscriptions, and the Claw sessions this worker made. */
|
|
35
37
|
readonly gate: {
|
|
36
38
|
readonly subscriptions: GateSubscriptions | undefined;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* of failure and dropped (a redelivery cannot make it readable).
|
|
6
6
|
*/
|
|
7
7
|
import type { InboundEvent, Logger } from "@primusclaw/personal-agent";
|
|
8
|
+
import { type GroupContextChanges } from "../activity/inbound/index.js";
|
|
8
9
|
import type { JsonObject } from "../cards/json.js";
|
|
9
10
|
import type { AckRegistry } from "../messenger/acks.js";
|
|
10
11
|
export declare const DELIVERED = "primusclaw.delivered";
|
|
@@ -13,6 +14,8 @@ export interface InboundParts {
|
|
|
13
14
|
readonly route: (event: InboundEvent) => Promise<void>;
|
|
14
15
|
readonly botName: string;
|
|
15
16
|
readonly logger?: Logger;
|
|
17
|
+
/** The recent messages kept of group chats: a removal, delete or edit in a group changes them (none: nothing kept). */
|
|
18
|
+
readonly groupContext?: GroupContextChanges;
|
|
16
19
|
}
|
|
17
20
|
/** The handler of one inbound body. */
|
|
18
21
|
export declare function inboundHandler(parts: InboundParts): (body: JsonObject) => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The platform services the Python worker always talks to, in place of the neutral plugins a deployment did not replace:
|
|
3
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), a key deleted at SaFE when it is given up (`safe.revoke_own_key`: /unlink, and pending keys
|
|
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
5
|
* nobody redeemed), and the GitHub issues a report is filed as (`FeedbackService`'s GitHub sink, when FEEDBACK_REPO
|
|
6
6
|
* and a credential are set). A plugin a deployment did replace is kept.
|
|
7
7
|
*/
|
|
@@ -5,10 +5,16 @@ export type Env = Readonly<Record<string, string | undefined>>;
|
|
|
5
5
|
export declare class TeamsConfigError extends Error {
|
|
6
6
|
name: string;
|
|
7
7
|
}
|
|
8
|
-
export type BotTokenSource = "imds" | "federated";
|
|
8
|
+
export type BotTokenSource = "imds" | "federated" | "secret";
|
|
9
9
|
export interface BotSettings {
|
|
10
10
|
readonly tokenSource: BotTokenSource;
|
|
11
11
|
readonly msiClientId: string;
|
|
12
|
+
/** BOT_CLIENT_ID: the app registration's client id, with `secret`. */
|
|
13
|
+
readonly clientId: string;
|
|
14
|
+
/** BOT_CLIENT_SECRET, with `secret` ("" otherwise). Not enumerable: a dump of the settings does not show it. */
|
|
15
|
+
readonly clientSecret: string;
|
|
16
|
+
/** BOT_CLIENT_SECRET is set but BOT_TOKEN_SOURCE names another source, which wins (the worker warns at start). */
|
|
17
|
+
readonly clientSecretIgnored: boolean;
|
|
12
18
|
readonly tenantId: string;
|
|
13
19
|
readonly assertionKeyFile: string;
|
|
14
20
|
readonly assertionIssuer: string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A token from Entra ID for an app registration's client secret (the OAuth client credentials grant): the most common
|
|
3
|
+
* way to run a bot outside Azure, where neither a managed identity nor a federated credential is at hand. By default the
|
|
4
|
+
* scope is the bot's Bot Connector scope.
|
|
5
|
+
*
|
|
6
|
+
* The secret goes into the token request's form and nowhere else: it is never logged, never part of an error message,
|
|
7
|
+
* and hidden from `JSON.stringify` and `util.inspect` of the provider. A refusal by Entra (400/401: wrong tenant, client
|
|
8
|
+
* id or secret, an expired secret) is not transient; a 429, a 5xx or a network error is. Errors name the AADSTS codes
|
|
9
|
+
* only, never the description (it can echo the request).
|
|
10
|
+
*/
|
|
11
|
+
import { type Clock, type Logger } from "@primusclaw/personal-agent";
|
|
12
|
+
import { CachedTokenProvider } from "./cached.js";
|
|
13
|
+
export interface ClientSecretOptions {
|
|
14
|
+
readonly clientId: string;
|
|
15
|
+
readonly tenantId: string;
|
|
16
|
+
readonly clientSecret: string;
|
|
17
|
+
readonly clock: Clock;
|
|
18
|
+
readonly fetch?: typeof fetch;
|
|
19
|
+
readonly logger?: Logger;
|
|
20
|
+
/** The token endpoint; default Entra ID's for the tenant. */
|
|
21
|
+
readonly url?: string;
|
|
22
|
+
readonly scope?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class ClientSecretTokenProvider extends CachedTokenProvider {
|
|
25
|
+
#private;
|
|
26
|
+
readonly source = "secret";
|
|
27
|
+
readonly scope: string;
|
|
28
|
+
readonly clientId: string;
|
|
29
|
+
readonly tenantId: string;
|
|
30
|
+
private readonly fetch;
|
|
31
|
+
private readonly logger;
|
|
32
|
+
private readonly url;
|
|
33
|
+
/** Throws (an Error naming the missing setting, never a value) rather than at the first token. */
|
|
34
|
+
constructor(options: ClientSecretOptions);
|
|
35
|
+
protected fetchToken(signal?: AbortSignal): Promise<string>;
|
|
36
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** How Teams shows the remote-agent views. */
|
|
2
2
|
import type { Renderers } from "../registry.js";
|
|
3
3
|
export { agentsCard, conversationBlocks } from "./agents-card.js";
|
|
4
|
-
export { decidedCard, permissionCard, remoteAskCard } from "./permission-cards.js";
|
|
4
|
+
export { decidedCard, permissionCard, remoteAskCard, terminalAskCard } from "./permission-cards.js";
|
|
5
5
|
export { connectBlocks, sessionsCard } from "./sessions-card.js";
|
|
6
6
|
export { disconnectButtons, disconnectCard, machineChoiceCard, modeCard, takeoverCard } from "./small-cards.js";
|
|
7
7
|
export { hiddenCard } from "./hidden-card.js";
|
|
8
8
|
export { statusCard } from "./status-card.js";
|
|
9
9
|
export { windowCard } from "./window-card.js";
|
|
10
|
-
type RemoteRenderers = Pick<Renderers, "remoteAgents" | "remoteSessions" | "remoteStatus" | "remotePermission" | "remoteAsk" | "remoteDecided" | "remoteDisconnect" | "remoteTakeover" | "remoteMachineChoice" | "remoteMode" | "remoteWindow" | "remoteHidden">;
|
|
10
|
+
type RemoteRenderers = Pick<Renderers, "remoteAgents" | "remoteSessions" | "remoteStatus" | "remotePermission" | "remoteAsk" | "terminalAsk" | "remoteDecided" | "remoteDisconnect" | "remoteTakeover" | "remoteMachineChoice" | "remoteMode" | "remoteWindow" | "remoteHidden">;
|
|
11
11
|
/** The remote-agent renderers. */
|
|
12
12
|
export declare const REMOTE_RENDERERS: RemoteRenderers;
|
|
@@ -5,5 +5,13 @@ import { type CardMessage } from "../../cards/kit.js";
|
|
|
5
5
|
export declare function permissionCard(view: remoteView.PermissionView): CardMessage;
|
|
6
6
|
/** The push for an agent on the user's machine that waits on them. */
|
|
7
7
|
export declare function remoteAskCard(view: remoteView.RemoteAskView): CardMessage;
|
|
8
|
+
/** The most a terminal's card may weigh as sent: Teams takes about 28 KB, and this leaves room for the activity around it. */
|
|
9
|
+
export declare const TERMINAL_CARD_SAFE_BYTES = 24000;
|
|
10
|
+
/**
|
|
11
|
+
* The card of a question a terminal asks: who asks, what, the content whole (or the notice that it is not), then the options.
|
|
12
|
+
* Whatever the request, the card goes out: one heavier than TERMINAL_CARD_SAFE_BYTES is sent cut short instead (only the options
|
|
13
|
+
* that turn it down), and if even that is too heavy, with its title, the notice to approve at the terminal and those options.
|
|
14
|
+
*/
|
|
15
|
+
export declare function terminalAskCard(view: remoteView.TerminalAskView): CardMessage;
|
|
8
16
|
/** What a permission card becomes once answered. */
|
|
9
17
|
export declare function decidedCard(view: remoteView.DecidedView): CardMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primusclaw/personal-agent-teams",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The personal agent on Microsoft Teams: activities, Adaptive Cards, streams, Bot Connector, inbound queue, process assembly.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@azure/core-auth": "^1.11.0",
|
|
33
33
|
"@azure/service-bus": "^7.10.0",
|
|
34
|
-
"@primusclaw/personal-agent": "0.
|
|
35
|
-
"@primusclaw/personal-agent-runtime": "0.
|
|
34
|
+
"@primusclaw/personal-agent": "0.3.0",
|
|
35
|
+
"@primusclaw/personal-agent-runtime": "0.3.0",
|
|
36
36
|
"zod": "^4.6.7"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|