@primusclaw/personal-agent-teams 0.0.0-stage → 0.1.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/LICENSE +37 -0
- package/dist/index.js +8817 -0
- package/dist/main.js +8739 -0
- package/dist/types/activity/decorations.d.ts +40 -0
- package/dist/types/activity/feedback-loop.d.ts +9 -0
- package/dist/types/activity/inbound/actions.d.ts +55 -0
- package/dist/types/activity/inbound/identity.d.ts +36 -0
- package/dist/types/activity/inbound/index.d.ts +9 -0
- package/dist/types/activity/inbound/links.d.ts +30 -0
- package/dist/types/activity/inbound/markup.d.ts +39 -0
- package/dist/types/activity/inbound/mentions.d.ts +37 -0
- package/dist/types/activity/inbound/patterns.d.ts +21 -0
- package/dist/types/activity/inbound/quotes-html.d.ts +17 -0
- package/dist/types/activity/inbound/quotes.d.ts +32 -0
- package/dist/types/activity/inbound/schema.d.ts +44 -0
- package/dist/types/activity/inbound/to-event.d.ts +24 -0
- package/dist/types/activity/outbound.d.ts +25 -0
- package/dist/types/activity/redact-activity.d.ts +16 -0
- package/dist/types/activity/reference.d.ts +9 -0
- package/dist/types/activity/stream-activity.d.ts +16 -0
- package/dist/types/assembly/features-assistant.d.ts +42 -0
- package/dist/types/assembly/features-base.d.ts +49 -0
- package/dist/types/assembly/features-proactive.d.ts +26 -0
- package/dist/types/assembly/features-remote.d.ts +13 -0
- package/dist/types/assembly/features-review.d.ts +31 -0
- package/dist/types/assembly/features-switches.d.ts +26 -0
- package/dist/types/assembly/features-text.d.ts +35 -0
- package/dist/types/assembly/features-turns.d.ts +19 -0
- package/dist/types/assembly/features-w8.d.ts +18 -0
- package/dist/types/assembly/features.d.ts +42 -0
- package/dist/types/assembly/http.d.ts +23 -0
- package/dist/types/assembly/inbound.d.ts +18 -0
- package/dist/types/assembly/outbound.d.ts +40 -0
- package/dist/types/assembly/plugins.d.ts +20 -0
- package/dist/types/assembly/runner.d.ts +28 -0
- package/dist/types/assembly/secrets.d.ts +11 -0
- package/dist/types/assembly/timers.d.ts +14 -0
- package/dist/types/assembly/worker-services.d.ts +23 -0
- package/dist/types/assembly/worker.d.ts +19 -0
- package/dist/types/azure/keyvault-config.d.ts +24 -0
- package/dist/types/azure/keyvault.d.ts +52 -0
- package/dist/types/azure/workload-identity.d.ts +56 -0
- package/dist/types/caps.d.ts +13 -0
- package/dist/types/cards/cjk.d.ts +9 -0
- package/dist/types/cards/json.d.ts +12 -0
- package/dist/types/cards/kit.d.ts +115 -0
- package/dist/types/cards/view-buttons.d.ts +4 -0
- package/dist/types/config/env.d.ts +48 -0
- package/dist/types/config/style.d.ts +32 -0
- package/dist/types/connector/errors.d.ts +34 -0
- package/dist/types/connector/hosts.d.ts +40 -0
- package/dist/types/connector/lanes.d.ts +10 -0
- package/dist/types/connector/limits.d.ts +23 -0
- package/dist/types/connector/outbox.d.ts +97 -0
- package/dist/types/connector/py-parse.d.ts +10 -0
- package/dist/types/connector/request.d.ts +21 -0
- package/dist/types/connector/response.d.ts +9 -0
- package/dist/types/connector/retry.d.ts +57 -0
- package/dist/types/connector/timer.d.ts +18 -0
- package/dist/types/connector/tokens/assertion.d.ts +38 -0
- package/dist/types/connector/tokens/cached.d.ts +33 -0
- package/dist/types/connector/tokens/federated.d.ts +41 -0
- package/dist/types/connector/tokens/http.d.ts +11 -0
- package/dist/types/connector/tokens/imds.d.ts +26 -0
- package/dist/types/feedback/vote.d.ts +10 -0
- package/dist/types/gate/entry-env.d.ts +25 -0
- package/dist/types/gate/no-queue.d.ts +22 -0
- package/dist/types/gate/routes.d.ts +34 -0
- package/dist/types/html/entities.d.ts +2 -0
- package/dist/types/html/html5-entities.d.ts +6 -0
- package/dist/types/html/lexer.d.ts +18 -0
- package/dist/types/inbound/attachments.d.ts +36 -0
- package/dist/types/inbound/download.d.ts +34 -0
- package/dist/types/inbound/fetcher.d.ts +63 -0
- package/dist/types/inbound/names.d.ts +2 -0
- package/dist/types/inbound/types.d.ts +24 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/main.d.ts +13 -0
- package/dist/types/messenger/acks.d.ts +23 -0
- package/dist/types/messenger/conversation.d.ts +59 -0
- package/dist/types/messenger/masker.d.ts +20 -0
- package/dist/types/messenger/render.d.ts +27 -0
- package/dist/types/observability/build-info.d.ts +7 -0
- package/dist/types/outbound/log-fields.d.ts +14 -0
- package/dist/types/outbound/outbox.d.ts +70 -0
- package/dist/types/richtext/blocks.d.ts +7 -0
- package/dist/types/richtext/check.d.ts +4 -0
- package/dist/types/richtext/constants.d.ts +15 -0
- package/dist/types/richtext/escape.d.ts +37 -0
- package/dist/types/richtext/index.d.ts +30 -0
- package/dist/types/richtext/inline.d.ts +11 -0
- package/dist/types/richtext/lines.d.ts +18 -0
- package/dist/types/richtext/scan.d.ts +17 -0
- package/dist/types/richtext/status.d.ts +9 -0
- package/dist/types/richtext/url.d.ts +2 -0
- package/dist/types/servicebus/client.d.ts +40 -0
- package/dist/types/servicebus/consumer.d.ts +53 -0
- package/dist/types/servicebus/outbox.d.ts +22 -0
- package/dist/types/stream/busy.d.ts +17 -0
- package/dist/types/stream/informative.d.ts +10 -0
- package/dist/types/stream/live-stream.d.ts +25 -0
- package/dist/types/stream/mutex.d.ts +6 -0
- package/dist/types/stream/teams-stream.d.ts +63 -0
- package/dist/types/surface.d.ts +46 -0
- package/dist/types/views/approval/index.d.ts +33 -0
- package/dist/types/views/assistant/index.d.ts +40 -0
- package/dist/types/views/commands/index.d.ts +26 -0
- package/dist/types/views/feedback/index.d.ts +23 -0
- package/dist/types/views/index.d.ts +3 -0
- package/dist/types/views/observe/index.d.ts +10 -0
- package/dist/types/views/proactive/index.d.ts +31 -0
- package/dist/types/views/registry.d.ts +21 -0
- package/dist/types/views/remote/agents-card.d.ts +10 -0
- package/dist/types/views/remote/elements.d.ts +18 -0
- package/dist/types/views/remote/hidden-card.d.ts +4 -0
- package/dist/types/views/remote/index.d.ts +12 -0
- package/dist/types/views/remote/permission-cards.d.ts +9 -0
- package/dist/types/views/remote/sessions-card.d.ts +8 -0
- package/dist/types/views/remote/small-cards.d.ts +14 -0
- package/dist/types/views/remote/status-card.d.ts +5 -0
- package/dist/types/views/remote/window-card.d.ts +5 -0
- package/dist/types/views/review/index.d.ts +21 -0
- package/dist/types/views/turn/index.d.ts +28 -0
- package/dist/types/views/turn/note.d.ts +10 -0
- package/dist/types/views/turn/stop.d.ts +8 -0
- package/dist/types/worker-api.d.ts +69 -0
- package/package.json +39 -4
- package/README.md +0 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** One token endpoint request through the injected fetch, bounded by its own timeout and the caller's signal. */
|
|
2
|
+
import { type Clock } from "@primusclaw/personal-agent";
|
|
3
|
+
export interface TokenHttp {
|
|
4
|
+
readonly fetch: typeof fetch;
|
|
5
|
+
readonly clock: Clock;
|
|
6
|
+
}
|
|
7
|
+
/** The status and the body text of one request; a network failure, a timeout or an abort is a transient TokenError. */
|
|
8
|
+
export declare function tokenRequest(http: TokenHttp, service: string, url: string, init: RequestInit, timeoutMs: number, signal?: AbortSignal): Promise<{
|
|
9
|
+
status: number;
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bot's Bot Connector token from Azure IMDS: the node's managed identity is the bot, so there is no secret. Cached
|
|
3
|
+
* until five minutes before it expires; concurrent callers share one fetch.
|
|
4
|
+
*/
|
|
5
|
+
import { type Clock, type Logger } from "@primusclaw/personal-agent";
|
|
6
|
+
import { CachedTokenProvider } from "./cached.js";
|
|
7
|
+
export declare const BOT_CONNECTOR_RESOURCE = "https://api.botframework.com";
|
|
8
|
+
export declare const IMDS_TOKEN_URL = "http://169.254.169.254/metadata/identity/oauth2/token";
|
|
9
|
+
export declare const IMDS_API_VERSION = "2018-02-01";
|
|
10
|
+
export declare const IMDS_TIMEOUT_MS = 5000;
|
|
11
|
+
export interface ImdsOptions {
|
|
12
|
+
readonly clock: Clock;
|
|
13
|
+
/** Default `globalThis.fetch` (which uses no proxy from the environment: IMDS is link-local and must never go through one). */
|
|
14
|
+
readonly fetch?: typeof fetch;
|
|
15
|
+
readonly logger?: Logger;
|
|
16
|
+
readonly url?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class ImdsTokenProvider extends CachedTokenProvider {
|
|
19
|
+
private readonly clientId;
|
|
20
|
+
readonly source = "imds";
|
|
21
|
+
private readonly fetch;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
private readonly url;
|
|
24
|
+
constructor(clientId: string, options: ImdsOptions);
|
|
25
|
+
protected fetchToken(signal?: AbortSignal): Promise<string>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Activity } from "../activity/inbound/schema.js";
|
|
2
|
+
export interface TeamsVote {
|
|
3
|
+
readonly reaction: "like" | "dislike";
|
|
4
|
+
/** What the person typed in Teams' form ("" when nothing). */
|
|
5
|
+
readonly comment: string;
|
|
6
|
+
}
|
|
7
|
+
/** The comment of a feedback form: `{"feedbackText": ...}` as JSON text or an object, or the words themselves. */
|
|
8
|
+
export declare function feedbackTextOf(raw: unknown): string;
|
|
9
|
+
/** The thumb an activity carries, if it is Teams' own thumbs invoke; undefined for anything else. */
|
|
10
|
+
export declare function voteOf(activity: Activity): TeamsVote | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the release gate's test entry is on (`--driver external`: the gate drives this worker from outside its process).
|
|
3
|
+
* Off unless the environment turns it on, and production never does. It is on only when TEAMS_GATE_ENTRY is exactly "1",
|
|
4
|
+
* GATE_RUN_ID (which only the gate's Job sets) is not empty, and TEAMS_GATE_CONNECTOR_URL is `http://127.0.0.1:<port>`;
|
|
5
|
+
* any other value of TEAMS_GATE_ENTRY stops the worker at start (a typo must not quietly pick a path).
|
|
6
|
+
*/
|
|
7
|
+
export declare const PREFIX = "/gate/v1";
|
|
8
|
+
export declare const FILES = "/gate-files/";
|
|
9
|
+
export declare const LOOPBACK = "127.0.0.1";
|
|
10
|
+
/** A person linked with `subscribe: false` makes no subscription of their own for a day. */
|
|
11
|
+
export declare const NO_SUBSCRIPTION_SECONDS: number;
|
|
12
|
+
export declare class GateEntryRefused extends Error {
|
|
13
|
+
name: string;
|
|
14
|
+
}
|
|
15
|
+
export interface GateEntry {
|
|
16
|
+
/** http://127.0.0.1:<port>, the recording Bot Connector of the gate run. */
|
|
17
|
+
readonly connectorUrl: string;
|
|
18
|
+
readonly runId: string;
|
|
19
|
+
/** Where the gate's files are fetched from (the one plain-http place the file fetcher takes). */
|
|
20
|
+
readonly filesPrefix: string;
|
|
21
|
+
}
|
|
22
|
+
/** `url` as `http://127.0.0.1:<port>`; refused when it is anything else (another host, https, a path, user info). */
|
|
23
|
+
export declare function loopbackUrl(url: string): string;
|
|
24
|
+
/** The test entry when the environment turns it on; undefined when it does not (TEAMS_GATE_ENTRY unset or empty). */
|
|
25
|
+
export declare function gateEntryFromEnv(env: Readonly<Record<string, string | undefined>>): GateEntry | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The test entry's stand-ins for what production has behind the Bot Connector: no queue (a send the recording connector
|
|
3
|
+
* did not take is dropped and logged; nothing of the gate reaches Service Bus or Teams) and a made-up bot token that goes
|
|
4
|
+
* only to the recording connector.
|
|
5
|
+
*/
|
|
6
|
+
import type { Logger } from "@primusclaw/personal-agent";
|
|
7
|
+
import type { TokenSource } from "../connector/tokens/cached.js";
|
|
8
|
+
import { type Delivered, type Outbox, type TeamsEnvelope } from "../outbound/outbox.js";
|
|
9
|
+
export declare class NoQueue implements Outbox {
|
|
10
|
+
private readonly logger;
|
|
11
|
+
constructor(logger?: Logger);
|
|
12
|
+
publish(envelope: TeamsEnvelope): Promise<Delivered | undefined>;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/** The bot's token in the test entry: made up, and sent only to the recording connector (its service-URL policy). */
|
|
16
|
+
export declare class GateToken implements TokenSource {
|
|
17
|
+
private readonly token;
|
|
18
|
+
constructor(runId: string);
|
|
19
|
+
get(): Promise<string>;
|
|
20
|
+
invalidate(): void;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The release gate's test entry, as HTTP routes on the worker's own server (127.0.0.1 only). The gate posts a person's
|
|
3
|
+
* message, file or press as the Bot Framework activity the inbound queue carries (`POST /gate/v1/activity`), links its
|
|
4
|
+
* made-up people (`PUT /gate/v1/people/<aad>`), reads a chat's session and a person's subscription (`GET`), makes or removes
|
|
5
|
+
* the subscription (`POST`/`DELETE .../subscription`) and lists the Claw sessions this worker made (`GET /gate/v1/sessions`,
|
|
6
|
+
* deleted at the end of a run). A worker in any language that implements these routes and the Bot Connector calls is driven
|
|
7
|
+
* by the same gate.
|
|
8
|
+
*/
|
|
9
|
+
import type { LinkRepository, Logger, MemberDirectoryRepository, NotifySubscriptionRepository, SessionRepository, TokenExchange } from "@primusclaw/personal-agent";
|
|
10
|
+
import { type HttpRoute } from "@primusclaw/personal-agent-runtime";
|
|
11
|
+
import type { JsonObject } from "../cards/json.js";
|
|
12
|
+
/** The person's notification subscription, as the assistant feature keeps it. */
|
|
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
|
+
}
|
|
19
|
+
export interface GateEntryDeps {
|
|
20
|
+
/** What the inbound queue's consumer hands an activity to. */
|
|
21
|
+
readonly handle: (activity: JsonObject) => Promise<void>;
|
|
22
|
+
readonly links: Pick<LinkRepository, "stashPending" | "redeemPending" | "setClawUserId">;
|
|
23
|
+
readonly members: Pick<MemberDirectoryRepository, "rememberMember">;
|
|
24
|
+
readonly notifySubs: Pick<NotifySubscriptionRepository, "claimNotifyAttempt" | "getNotifySub">;
|
|
25
|
+
readonly sessions: Pick<SessionRepository, "getSession">;
|
|
26
|
+
readonly exchange: TokenExchange;
|
|
27
|
+
/** undefined: proactive messages are off, so there are no subscriptions. */
|
|
28
|
+
readonly subscriptions: GateSubscriptions | undefined;
|
|
29
|
+
/** The ids of the Claw sessions this worker made, in order. */
|
|
30
|
+
readonly madeSessions: () => readonly string[];
|
|
31
|
+
readonly logger?: Logger;
|
|
32
|
+
}
|
|
33
|
+
/** Every route of the test entry, to mount on the worker's server before it starts. */
|
|
34
|
+
export declare function gateRoutes(deps: GateEntryDeps): HttpRoute[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML5's named character references, all 2,231 of them, exactly as Python's `html.entities.html5` has them (the table
|
|
3
|
+
* `html.unescape` reads): `name=hex[,hex]`, separated by `|`. A name that ends without its semicolon is one that may be
|
|
4
|
+
* written without it. Generated from Python 3 (`sorted(html.entities.html5.items())`); not edited by hand.
|
|
5
|
+
*/
|
|
6
|
+
export declare const HTML5_ENTITIES: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** An attribute: its lower-cased name and its decoded value (null when it has no `=`). */
|
|
2
|
+
export type HtmlAttr = readonly [name: string, value: string | null];
|
|
3
|
+
export type HtmlToken = {
|
|
4
|
+
readonly kind: "start";
|
|
5
|
+
readonly tag: string;
|
|
6
|
+
readonly attrs: readonly HtmlAttr[];
|
|
7
|
+
readonly selfClosing: boolean;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "end";
|
|
10
|
+
readonly tag: string;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "data";
|
|
13
|
+
readonly text: string;
|
|
14
|
+
};
|
|
15
|
+
/** The value of attribute `name`, the last one when it is given twice (Python's `dict(attrs)`); undefined when absent. */
|
|
16
|
+
export declare function attrValue(attrs: readonly HtmlAttr[], name: string): string | null | undefined;
|
|
17
|
+
/** The tokens of `markup`, in order; adjacent text is one token. */
|
|
18
|
+
export declare function tokenize(markup: string): HtmlToken[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The files a message brings, read from `activity.attachments`, next to the `text/html` copy of the message and any
|
|
3
|
+
* cards:
|
|
4
|
+
* - an image pasted into the message: `contentType` "image/*" (or a concrete image type) and a `contentUrl` on the Bot
|
|
5
|
+
* Connector, fetched with the bot's own token;
|
|
6
|
+
* - a file sent in a 1:1 chat: `contentType` FILE_DOWNLOAD_INFO, whose `content.downloadUrl` is a short-lived link
|
|
7
|
+
* that needs no token (Teams sends these only to a bot whose manifest says `supportsFiles: true`);
|
|
8
|
+
* - anything else that names a file (a file shared into a group chat is a link to SharePoint, which the bot has no
|
|
9
|
+
* right to read): reported back to the user by name, never fetched.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { type InboundFile } from "@primusclaw/personal-agent";
|
|
13
|
+
export declare const FILE_DOWNLOAD_INFO = "application/vnd.microsoft.teams.file.download.info";
|
|
14
|
+
/** How a file is fetched: a pasted image from the Bot Connector with the bot's token, or a download link without one. */
|
|
15
|
+
export type TeamsFileKind = "pasted" | "download";
|
|
16
|
+
/** What `InboundFile.handle` holds for a Teams file: where it is, how to fetch it, its 1-based place among the files. */
|
|
17
|
+
export interface TeamsFileHandle {
|
|
18
|
+
readonly kind: TeamsFileKind;
|
|
19
|
+
readonly url: string;
|
|
20
|
+
readonly index: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const teamsFileHandle: z.ZodObject<{
|
|
23
|
+
kind: z.ZodEnum<{
|
|
24
|
+
pasted: "pasted";
|
|
25
|
+
download: "download";
|
|
26
|
+
}>;
|
|
27
|
+
url: z.ZodString;
|
|
28
|
+
index: z.ZodNumber;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
/** The files of a message the worker can fetch, and the names of those it cannot. */
|
|
31
|
+
export interface MessageFiles {
|
|
32
|
+
readonly files: InboundFile[];
|
|
33
|
+
readonly unreadable: string[];
|
|
34
|
+
}
|
|
35
|
+
/** (the files of `activity` the worker can fetch, the names of those it cannot). */
|
|
36
|
+
export declare function inboundFiles(activity: unknown): MessageFiles;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One HTTP GET of a file: redirects followed by hand so the bot's token never follows one to another origin, the body
|
|
3
|
+
* counted as it arrives and abandoned past the size limit, and every wait (the answer, each chunk) limited by an idle
|
|
4
|
+
* timeout on the injected clock. What goes wrong is said in words for the user (`NotFetched`); the log gets the status
|
|
5
|
+
* or the error's kind, never the URL.
|
|
6
|
+
*/
|
|
7
|
+
import { type Clock, type Logger } from "@primusclaw/personal-agent";
|
|
8
|
+
/** How long one wait (the answer, the next chunk) may take, like httpx's per-operation timeout. */
|
|
9
|
+
export declare const FETCH_TIMEOUT_MS = 60000;
|
|
10
|
+
/** httpx's default limit. */
|
|
11
|
+
export declare const MAX_REDIRECTS = 20;
|
|
12
|
+
/** The `fetch` the fetcher uses (the global one in production; a fake in tests). */
|
|
13
|
+
export type FetchLike = (url: string, init: RequestInit) => Promise<Response>;
|
|
14
|
+
/** Why one file was not fetched, in words for the user. */
|
|
15
|
+
export declare class NotFetched extends Error {
|
|
16
|
+
name: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Downloaded {
|
|
19
|
+
readonly bytes: Uint8Array;
|
|
20
|
+
readonly mediaType: string;
|
|
21
|
+
}
|
|
22
|
+
export interface DownloadOptions {
|
|
23
|
+
readonly fetch: FetchLike;
|
|
24
|
+
readonly clock: Clock;
|
|
25
|
+
readonly logger: Logger;
|
|
26
|
+
readonly maxBytes: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* httpx's rule for the Authorization header on a redirect: kept to the same origin (scheme, host, port), and on the
|
|
30
|
+
* upgrade of the same host from http to https on the default ports; dropped everywhere else.
|
|
31
|
+
*/
|
|
32
|
+
export declare function keepsAuthorization(from: URL, to: URL): boolean;
|
|
33
|
+
/** The file at `url`; throws NotFetched with the reason in the user's words. */
|
|
34
|
+
export declare function download(url: string, headers: Record<string, string>, options: DownloadOptions): Promise<Downloaded>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches the files `inboundFiles` found: a pasted image from the Bot Connector with the bot's token (and only from a
|
|
3
|
+
* Bot Connector host), a sent file's download link without one (https only). Files off the allowlist are never fetched,
|
|
4
|
+
* a pasted image whose bytes are no PNG, JPEG, GIF or WebP is not passed on, and each fetched file gets a name that is
|
|
5
|
+
* one safe path component. File names, URLs and bytes are never logged.
|
|
6
|
+
*/
|
|
7
|
+
import { type Clock, type FetchedFile, type FileRefused, type InboundFile, type Logger, type Result } from "@primusclaw/personal-agent";
|
|
8
|
+
import { type ServiceUrlPolicy } from "../connector/hosts.js";
|
|
9
|
+
import { type FetchLike } from "./download.js";
|
|
10
|
+
/** Per message; the rest are named back to the user. */
|
|
11
|
+
export declare const MAX_FILES = 10;
|
|
12
|
+
export declare const MAX_FILE_BYTES: number;
|
|
13
|
+
/** The bot's Bot Connector token source (the one direct delivery uses). */
|
|
14
|
+
export interface BotTokens {
|
|
15
|
+
get(): Promise<string>;
|
|
16
|
+
}
|
|
17
|
+
export interface TeamsFileFetcherOptions {
|
|
18
|
+
readonly fetch: FetchLike;
|
|
19
|
+
readonly clock: Clock;
|
|
20
|
+
/** Without one (the worker is on the queue path) a pasted image cannot be fetched and is reported as such. */
|
|
21
|
+
readonly tokens?: BotTokens | undefined;
|
|
22
|
+
/** Where the bot's token may go (the Bot Connector hosts; the release gate's recording connector in its test entry). */
|
|
23
|
+
readonly hosts?: ServiceUrlPolicy;
|
|
24
|
+
/**
|
|
25
|
+
* The release gate's test entry only: a plain-http prefix (the gate's own files on 127.0.0.1) a download link may
|
|
26
|
+
* start with. "" (production): a link that needs no token must be https.
|
|
27
|
+
*/
|
|
28
|
+
readonly plainPrefix?: string;
|
|
29
|
+
readonly maxFileBytes?: number;
|
|
30
|
+
readonly logger?: Logger;
|
|
31
|
+
}
|
|
32
|
+
/** A file that did not get through: the name it is shown by (`shownFileName`) and why, in words for the user. */
|
|
33
|
+
export interface FailedFile {
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly reason: string;
|
|
36
|
+
}
|
|
37
|
+
export interface FetchedFiles {
|
|
38
|
+
readonly fetched: FetchedFile[];
|
|
39
|
+
readonly failed: FailedFile[];
|
|
40
|
+
}
|
|
41
|
+
/** The name a file is called by when it is said back: its own, or "image <n>" for a pasted image (1-based). */
|
|
42
|
+
export declare function shownFileName(file: InboundFile, index: number): string;
|
|
43
|
+
export declare class TeamsFileFetcher {
|
|
44
|
+
private readonly fetchImpl;
|
|
45
|
+
private readonly clock;
|
|
46
|
+
private readonly tokens;
|
|
47
|
+
private readonly hosts;
|
|
48
|
+
private readonly plainPrefix;
|
|
49
|
+
private readonly maxFileBytes;
|
|
50
|
+
private readonly logger;
|
|
51
|
+
constructor(options: TeamsFileFetcherOptions);
|
|
52
|
+
/**
|
|
53
|
+
* The files of one message: those fetched, and the rest with why not. Never fails for one file: the others still go.
|
|
54
|
+
* Two files with one name do not overwrite each other (the later one is prefixed with its place).
|
|
55
|
+
*/
|
|
56
|
+
fetchAll(files: readonly InboundFile[]): Promise<FetchedFiles>;
|
|
57
|
+
/** `Surface.fetchFile`: one file, numbered by its place in its message (`handle.index`). */
|
|
58
|
+
fetchFile(file: InboundFile): Promise<Result<FetchedFile, FileRefused>>;
|
|
59
|
+
/** The file, or why it was not fetched. */
|
|
60
|
+
private fetchOne;
|
|
61
|
+
/** The request headers for `handle`; throws NotFetched when the file may not be fetched at all. */
|
|
62
|
+
private headers;
|
|
63
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which files a message may bring: the allowlist of sent-file types, a sent file's type (Teams' `fileType`, else the
|
|
3
|
+
* extension of its name), why a file is refused for its type, and what a pasted image's bytes say it is.
|
|
4
|
+
*
|
|
5
|
+
* A pasted image is never judged by a type it claims: its bytes are checked once fetched (`imageType`), and only PNG,
|
|
6
|
+
* JPEG, GIF and WebP are taken.
|
|
7
|
+
*/
|
|
8
|
+
import { type InboundFile } from "@primusclaw/personal-agent";
|
|
9
|
+
/**
|
|
10
|
+
* What a file sent in a chat may be: text, logs, data, code, documents, images, audio, video and the common archives of
|
|
11
|
+
* them. Not on it: programs and installers (exe, msi, dll, apk, jar, ...), Windows scripts and shortcuts (bat, cmd,
|
|
12
|
+
* ps1, vbs, lnk, ...), disk images, Office files with macros (docm, xlsm, ...), and anything without a type.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ALLOWED_FILE_TYPES: ReadonlySet<string>;
|
|
15
|
+
/** What a pasted image's bytes must be (`imageType`). */
|
|
16
|
+
export declare const PASTED_IMAGE_TYPES: readonly string[];
|
|
17
|
+
/** The image type the bytes say ("png", "jpg", "gif", "webp"), or "" when they are none of those. */
|
|
18
|
+
export declare function imageType(bytes: Uint8Array): string;
|
|
19
|
+
/** Whether a file is an image pasted into the message (fetched with the bot's token), not a sent file. */
|
|
20
|
+
export declare function isPasted(file: InboundFile): boolean;
|
|
21
|
+
/** A sent file's type: Teams' `fileType`, else the extension of its name ("" none). A pasted image is typed by its bytes. */
|
|
22
|
+
export declare function fileType(file: InboundFile): string;
|
|
23
|
+
/** Why a file is not taken for its type ("" when it is): the user is told this, then the types that are. */
|
|
24
|
+
export declare function refusedType(file: InboundFile): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @primusclaw/personal-agent-teams: the personal agent on Microsoft Teams. It implements core's Surface for Teams and
|
|
3
|
+
* assembles the worker process; it depends on core and on the runtime's public interface.
|
|
4
|
+
*/
|
|
5
|
+
export * from "./caps.js";
|
|
6
|
+
export * from "./activity/reference.js";
|
|
7
|
+
export * from "./cards/cjk.js";
|
|
8
|
+
export * from "./cards/kit.js";
|
|
9
|
+
export * from "./cards/view-buttons.js";
|
|
10
|
+
export type { CardElement, Json, JsonObject as CardJson } from "./cards/json.js";
|
|
11
|
+
export * from "./surface.js";
|
|
12
|
+
export * from "./views/index.js";
|
|
13
|
+
export * from "./worker-api.js";
|
|
14
|
+
export { buildWorker } from "./assembly/worker.js";
|
|
15
|
+
export { main } from "./main.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The worker as a program (from personal-agent/: `node --import tsx packages/teams/src/main.ts`): built from the
|
|
3
|
+
* environment with the neutral plugins, run until a signal. A worker that cannot start says why in one CRITICAL line,
|
|
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
|
+
*/
|
|
6
|
+
import { type Plugins } from "@primusclaw/personal-agent";
|
|
7
|
+
import type { PluginFactory, WorkerEnv } from "./worker-api.js";
|
|
8
|
+
/**
|
|
9
|
+
* Build and run a worker with `plugins` (a deployment's own entry passes its plugins or its factory; the public program the
|
|
10
|
+
* neutral ones); the exit status the process should end with. Every entry ends the same way: one CRITICAL line, 2 for a
|
|
11
|
+
* secret that cannot be read, 1 for anything else.
|
|
12
|
+
*/
|
|
13
|
+
export declare function main(env: WorkerEnv, plugins?: Plugins | PluginFactory, write?: (line: string) => void): Promise<number>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Acks of queued messages: a message that went through the outbound queue learns its Teams id later, when the relay
|
|
3
|
+
* sends `primusclaw.delivered` back in. This matches each ack to the post waiting for it, and tells a late ack (the post
|
|
4
|
+
* stopped waiting) from a stray one.
|
|
5
|
+
*/
|
|
6
|
+
import type { Clock, Logger } from "@primusclaw/personal-agent";
|
|
7
|
+
/** How many acks whose post stopped waiting are remembered, to log a late one as late. */
|
|
8
|
+
export declare const LATE_ACKS_REMEMBERED = 64;
|
|
9
|
+
/** What a post waits for: the Teams id of its message (`undefined` when the relay gave none). */
|
|
10
|
+
export interface AckWaiter {
|
|
11
|
+
readonly promise: Promise<string | undefined>;
|
|
12
|
+
}
|
|
13
|
+
export declare class AckRegistry {
|
|
14
|
+
private readonly clock;
|
|
15
|
+
private readonly logger;
|
|
16
|
+
private readonly waiting;
|
|
17
|
+
private readonly gaveUpAt;
|
|
18
|
+
constructor(clock: Clock, logger?: Logger);
|
|
19
|
+
expect(ack: string): AckWaiter;
|
|
20
|
+
forget(ack: string): void;
|
|
21
|
+
gaveUp(ack: string): void;
|
|
22
|
+
resolve(ack: string, activityId: string | undefined): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One Teams conversation's outbound side (core's `Conversation`, the Python worker's `Messenger`): posting, editing and
|
|
3
|
+
* deleting messages through the outbox, waiting for the id of a queued message, and opening a stream. Every operation
|
|
4
|
+
* leaves one log line (what, to which conversation, how long, whether an ack is awaited; never the text): after a turn
|
|
5
|
+
* it is the only trace of what the worker handed to Teams. In a group chat everything posted is masked first.
|
|
6
|
+
*/
|
|
7
|
+
import type { Clock, Conversation, ConversationRef, DeleteUnsupported, Envelope, LiveStream, Logger, MessageId, OutMessage, Random, Result, StreamRefused, UpdateOptions } from "@primusclaw/personal-agent";
|
|
8
|
+
import { type Outbox } from "../outbound/outbox.js";
|
|
9
|
+
import { type StreamContext } from "../stream/live-stream.js";
|
|
10
|
+
import type { AckRegistry } from "./acks.js";
|
|
11
|
+
import { type RenderContext } from "./render.js";
|
|
12
|
+
/**
|
|
13
|
+
* How long a post waits for Teams' id of a message that went through the queue: the relay Function scales to zero, and in
|
|
14
|
+
* the one measured case the ack landed 15-44 s after the post. A shorter wait loses the id, so a progress message could
|
|
15
|
+
* not be edited and would stay beside the answer.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ACK_TIMEOUT_MS = 60000;
|
|
18
|
+
/** A publish slower than this is logged: it is time the person waits (a stale connection reopening). */
|
|
19
|
+
export declare const SLOW_PUBLISH_MS = 1000;
|
|
20
|
+
export interface ConversationParts {
|
|
21
|
+
readonly ref: ConversationRef;
|
|
22
|
+
readonly outbox: Outbox;
|
|
23
|
+
readonly acks: AckRegistry;
|
|
24
|
+
readonly clock: Clock;
|
|
25
|
+
readonly random: Random;
|
|
26
|
+
readonly render: RenderContext;
|
|
27
|
+
readonly stream: StreamContext;
|
|
28
|
+
readonly ackTimeoutMs?: number;
|
|
29
|
+
readonly logger?: Logger;
|
|
30
|
+
}
|
|
31
|
+
export declare class TeamsConversation implements Conversation {
|
|
32
|
+
private readonly parts;
|
|
33
|
+
readonly edited: Set<string>;
|
|
34
|
+
private readonly logger;
|
|
35
|
+
constructor(parts: ConversationParts);
|
|
36
|
+
/** A message the bot removed or replaced elsewhere is settled: an unsettled click on it then leaves it alone. */
|
|
37
|
+
markSettled(id: MessageId): void;
|
|
38
|
+
get ref(): ConversationRef;
|
|
39
|
+
private get masker();
|
|
40
|
+
/** The activity as it is posted here: masked in a group chat. */
|
|
41
|
+
private prepare;
|
|
42
|
+
private publish;
|
|
43
|
+
typing(): Promise<void>;
|
|
44
|
+
outgoing(message: OutMessage): Envelope;
|
|
45
|
+
deliver(stored: Envelope): Promise<void>;
|
|
46
|
+
send(message: OutMessage): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Send and return Teams' id of the new message; undefined if it never arrives. A direct send returns the id itself; a
|
|
49
|
+
* message that went through the queue is waited for until its ack arrives (best effort: a caller that gets undefined keeps
|
|
50
|
+
* sending new messages instead of editing).
|
|
51
|
+
*/
|
|
52
|
+
post(message: OutMessage): Promise<MessageId | undefined>;
|
|
53
|
+
/** Replace the message `id`. With `signal`: a caller that was cancelled while it waited sends nothing. */
|
|
54
|
+
update(id: MessageId, message: OutMessage, options?: UpdateOptions): Promise<void>;
|
|
55
|
+
/** Remove a message this bot posted; refused when it could not be removed (the queue cannot delete; Teams may refuse). */
|
|
56
|
+
delete(id: MessageId): Promise<Result<void, DeleteUnsupported>>;
|
|
57
|
+
openStream(replyTo: MessageId, status: string): Promise<Result<LiveStream, StreamRefused>>;
|
|
58
|
+
}
|
|
59
|
+
export declare function refusal(reason: string, status?: number, code?: string): StreamRefused;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential masking of what a group chat is told: every member sees it, and an agent that reads a workload's environment
|
|
3
|
+
* can put a key into its answer. The masking rules are core's (`redact`); this is the shape the Teams side applies them in.
|
|
4
|
+
*/
|
|
5
|
+
import type { JsonObject } from "../cards/json.js";
|
|
6
|
+
export interface Masked {
|
|
7
|
+
readonly text: string;
|
|
8
|
+
/** Whether anything was masked. */
|
|
9
|
+
readonly hit: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface Masker {
|
|
12
|
+
/** `text` with every credential shape masked. */
|
|
13
|
+
text(text: string): Masked;
|
|
14
|
+
/** `activity` with every credential shape in its text and cards masked (a typing indicator passes through). */
|
|
15
|
+
activity(activity: JsonObject): JsonObject;
|
|
16
|
+
/** The line added under an answer something was masked in. */
|
|
17
|
+
readonly note: string;
|
|
18
|
+
}
|
|
19
|
+
/** Masks nothing: a 1:1 chat, where only the person sees what their own agent wrote. */
|
|
20
|
+
export declare const noMasking: Masker;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core's `OutMessage` as the Teams activity it is posted as: the body (markdown text, rich text as Teams' HTML subset, or a
|
|
3
|
+
* view rendered as a card) and the decorations core asked for (the AI label, @mentions, Teams' thumbs, suggested replies,
|
|
4
|
+
* citations), each applied only where Teams takes it.
|
|
5
|
+
*/
|
|
6
|
+
import type { Citation, OutMessage } from "@primusclaw/personal-agent";
|
|
7
|
+
import type { JsonObject } from "../cards/json.js";
|
|
8
|
+
import type { Style } from "../config/style.js";
|
|
9
|
+
import { type Renderers } from "../views/registry.js";
|
|
10
|
+
import type { Masker } from "./masker.js";
|
|
11
|
+
export interface RenderContext {
|
|
12
|
+
readonly style: Style;
|
|
13
|
+
readonly renderers: Renderers;
|
|
14
|
+
/** In a group chat: what everyone sees is masked. */
|
|
15
|
+
readonly masker: Masker | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A final answer as an xml-format message. In a group the masking runs on the markdown BEFORE it is converted (a mask that
|
|
19
|
+
* swallows to the end of an unfinished private key must not swallow a closing tag); conversion also resolves markdown
|
|
20
|
+
* escapes, which can make a secret recognisable only afterwards, so then the escapes are resolved first and the answer is
|
|
21
|
+
* masked again. Markup that still holds a secret shape is never sent: the masked markdown goes out instead.
|
|
22
|
+
*/
|
|
23
|
+
export declare function richActivity(markdown: string, lead: boolean, masker: Masker | undefined): JsonObject;
|
|
24
|
+
/** A citation as Teams' Claim entity; its position is the `[n]` the text cites it by. */
|
|
25
|
+
export declare function claimOf(citation: Citation): JsonObject;
|
|
26
|
+
/** The activity Teams is sent for `message` (before a group chat's masking of the whole activity). */
|
|
27
|
+
export declare function activityOf(message: OutMessage, context: RenderContext): JsonObject;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const BUILD_INFO_METRIC = "personal_agent_build_info";
|
|
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;
|
|
4
|
+
/** The teams package's version, read from its package.json (in the sources and in the published package alike). */
|
|
5
|
+
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;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an outbound log line says about where an envelope goes and what it is, so that a delivery can be traced to its
|
|
3
|
+
* conversation: the target conversation's id (`conversation`, from the envelope's reference, the id the Bot Connector
|
|
4
|
+
* posts to; "-" when the reference has none) and what kind of activity it is (`content`: "card" for a message carrying
|
|
5
|
+
* a card attachment, else the activity's type, such as "message" or "typing"; "-" when it has none). Ids and kinds
|
|
6
|
+
* only: never the text, a name or any other identity of a person.
|
|
7
|
+
*/
|
|
8
|
+
import { type JsonObject } from "../cards/json.js";
|
|
9
|
+
export interface OutboundLogFields {
|
|
10
|
+
readonly conversation: string;
|
|
11
|
+
readonly content: string;
|
|
12
|
+
}
|
|
13
|
+
/** The target conversation's id and the activity's kind, for an outbound log line. */
|
|
14
|
+
export declare function outboundLogFields(envelope: JsonObject): OutboundLogFields;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a conversation's outbound envelopes go: the outbound queue (a relay Function posts them) or the Bot Connector
|
|
3
|
+
* directly. The envelope is the contract of the outbound queue, byte for byte the Python worker's:
|
|
4
|
+
* `{"operation", "reference", "activity", ["activity_id"], ["ack"]}`.
|
|
5
|
+
*/
|
|
6
|
+
import type { JsonObject } from "../cards/json.js";
|
|
7
|
+
export type Operation = "send" | "reply" | "update" | "delete";
|
|
8
|
+
/** One outbound envelope. `reference` is the conversation reference (`activity.referenceOf`), `activity` the message. */
|
|
9
|
+
export interface TeamsEnvelope extends JsonObject {
|
|
10
|
+
operation: Operation;
|
|
11
|
+
reference: JsonObject;
|
|
12
|
+
activity: JsonObject;
|
|
13
|
+
activity_id?: string;
|
|
14
|
+
ack?: string;
|
|
15
|
+
}
|
|
16
|
+
/** What an outbox that posts to Teams itself returns: the id Teams gave the message (undefined when it gave none). */
|
|
17
|
+
export interface Delivered {
|
|
18
|
+
readonly activityId: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A message could not be deleted: only a direct send to the Bot Connector can delete one (the relay Function's contract
|
|
22
|
+
* is send, reply and update), so the queue, or a direct delete that Teams refused, ends here.
|
|
23
|
+
*/
|
|
24
|
+
export declare class DeleteUnsupportedError extends Error {
|
|
25
|
+
name: string;
|
|
26
|
+
}
|
|
27
|
+
/** The bot's 1:1 conversation with a user could not be created; the message is the reason (a status), never a body. */
|
|
28
|
+
export declare class ConversationNotOpenedError extends Error {
|
|
29
|
+
name: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A request of a Teams stream was not taken: Teams refused it (`status`, and its error code such as
|
|
33
|
+
* ContentStreamNotAllowed), nothing answered (status 0), or this outbox cannot stream at all (the queue).
|
|
34
|
+
*/
|
|
35
|
+
export declare class StreamRefusedError extends Error {
|
|
36
|
+
readonly status: number;
|
|
37
|
+
readonly code: string;
|
|
38
|
+
name: string;
|
|
39
|
+
constructor(reason: string, status?: number, code?: string);
|
|
40
|
+
}
|
|
41
|
+
/** The members of a group chat as the Bot Connector lists them (`id`, `name`, `objectId`, `givenName`, ...). */
|
|
42
|
+
export type ConnectorMember = JsonObject;
|
|
43
|
+
export interface PublishOptions {
|
|
44
|
+
/**
|
|
45
|
+
* The caller no longer wants it sent (its turn was cancelled): checked after any wait for the conversation's turn and
|
|
46
|
+
* before the request goes out; an aborted publish rejects with the signal's reason and sends nothing.
|
|
47
|
+
*/
|
|
48
|
+
readonly signal?: AbortSignal | undefined;
|
|
49
|
+
}
|
|
50
|
+
export interface Outbox {
|
|
51
|
+
/**
|
|
52
|
+
* Hand one envelope to Teams. Delivered: it is posted. undefined: it is on the outbound queue, and an ack, if the
|
|
53
|
+
* envelope asked for one, follows from the relay. A `delete` is either delivered or throws DeleteUnsupportedError.
|
|
54
|
+
*/
|
|
55
|
+
publish(envelope: TeamsEnvelope, options?: PublishOptions): Promise<Delivered | undefined>;
|
|
56
|
+
close(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/** An outbox that posts to the Bot Connector itself (direct mode): the only one that can stream, open a 1:1 chat, list members. */
|
|
59
|
+
export interface DirectOutbox extends Outbox {
|
|
60
|
+
/**
|
|
61
|
+
* One request of a Teams stream, sent once, directly. Throws StreamRefusedError when it was not taken; once
|
|
62
|
+
* `options.signal` aborts (the stream was dropped), it rejects with the signal's reason and leaves nothing waiting.
|
|
63
|
+
*/
|
|
64
|
+
publishStream(envelope: TeamsEnvelope, options?: PublishOptions): Promise<Delivered>;
|
|
65
|
+
/** The bot's 1:1 conversation id with `userId`; throws ConversationNotOpenedError. */
|
|
66
|
+
openPersonal(serviceUrl: string, userId: string, tenantId: string, botId: string): Promise<string>;
|
|
67
|
+
/** The members of a group chat; throws when Teams did not answer. */
|
|
68
|
+
listMembers(serviceUrl: string, conversationId: string): Promise<ConnectorMember[]>;
|
|
69
|
+
}
|
|
70
|
+
export declare function isDirect(outbox: Outbox): outbox is DirectOutbox;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `markdown` as Teams xml. `lead`: the answer's first line is its verdict, so a bold first line is the heading; a
|
|
3
|
+
* later part of a long answer passes false. Throws RichTextError when the result is not safe or too long.
|
|
4
|
+
*/
|
|
5
|
+
export declare function toTeamsHtml(markdown: string, options?: {
|
|
6
|
+
readonly lead?: boolean;
|
|
7
|
+
}): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The fixed numbers and colours of the Teams rich-text converter: heading sizes, status colours and the size limits. */
|
|
2
|
+
export declare const LEAD_PX = 16;
|
|
3
|
+
export declare const LABEL_PX = 15;
|
|
4
|
+
/** >= 3.3:1 on white, #f5f5f5, #292929 and #1f1f1f, so readable in light and dark themes. */
|
|
5
|
+
export declare const STATUS_COLORS: Readonly<Record<string, string>>;
|
|
6
|
+
export declare const MAX_INPUT_CHARS = 20000;
|
|
7
|
+
export declare const MAX_OUTPUT_BYTES = 22000;
|
|
8
|
+
export declare const MAX_NEST = 6;
|
|
9
|
+
export declare const MAX_LABEL_CHARS = 40;
|
|
10
|
+
export declare const MAX_URL_CHARS = 2000;
|
|
11
|
+
export declare const LINK_SCAN = 500;
|
|
12
|
+
/** What the converter throws when it cannot convert an answer safely; the caller then sends the markdown itself. */
|
|
13
|
+
export declare class RichTextError extends Error {
|
|
14
|
+
readonly name = "RichTextError";
|
|
15
|
+
}
|