@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,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reply style's decorations of an outbound activity: Teams' "AI generated" label and citations (both in ONE schema.org
|
|
3
|
+
* Message root entity: an activity with two is refused, 400 "Multiple root message entities"), and suggested replies; and
|
|
4
|
+
* the same activity without them, for a second try when Teams refused them.
|
|
5
|
+
*/
|
|
6
|
+
import { type JsonObject } from "../cards/json.js";
|
|
7
|
+
export declare const ROOT_ENTITY_TYPE = "https://schema.org/Message";
|
|
8
|
+
export declare const AI_GENERATED = "AIGeneratedContent";
|
|
9
|
+
/** Teams shows at most 20 citations on a message. */
|
|
10
|
+
export declare const CITATIONS_MAX = 20;
|
|
11
|
+
/** Teams shows the first three suggested replies only. */
|
|
12
|
+
export declare const SUGGESTIONS_MAX = 3;
|
|
13
|
+
/** The activity's entities that are JSON objects (anything else in the list is dropped, as the Python worker did). */
|
|
14
|
+
export declare function entitiesOf(activity: JsonObject): JsonObject[];
|
|
15
|
+
/**
|
|
16
|
+
* A copy of `activity` whose one root entity also has `fields` (an `additionalType` list is added to, a `citation` list
|
|
17
|
+
* appended to; anything else is set). Every other entity is kept, in its place; several roots are merged into the first's.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withRootEntity(activity: JsonObject, fields: JsonObject): JsonObject;
|
|
20
|
+
/** A copy of `activity` that Teams shows with its "AI generated" label. */
|
|
21
|
+
export declare function withAiLabel(activity: JsonObject): JsonObject;
|
|
22
|
+
/** The schema.org Message root entities of an activity (Teams takes at most one). */
|
|
23
|
+
export declare function rootEntities(activity: JsonObject): JsonObject[];
|
|
24
|
+
/** A copy of `activity` with `citations` in its one root entity (the activity itself when there are none). */
|
|
25
|
+
export declare function withCitationEntities(activity: JsonObject, citations: readonly JsonObject[]): JsonObject;
|
|
26
|
+
/** One suggested reply: the title shown, and the text sent as the person's message. */
|
|
27
|
+
export interface Suggestion {
|
|
28
|
+
readonly title: string;
|
|
29
|
+
readonly value: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A copy of `activity` with Teams' suggested replies under it, at most SUGGESTIONS_MAX. Teams shows them only on a
|
|
33
|
+
* message without attachments (the activity itself is returned for one with attachments, or when none is left).
|
|
34
|
+
*/
|
|
35
|
+
export declare function withSuggestedReplies(activity: JsonObject, replies: readonly Suggestion[]): JsonObject;
|
|
36
|
+
/**
|
|
37
|
+
* `activity` without what only Teams' newer clients understand (the root entity with the AI label and citations, the
|
|
38
|
+
* suggested replies), for a second try when Teams refused the activity with them (400). undefined: it has none of them.
|
|
39
|
+
*/
|
|
40
|
+
export declare function plainDecorations(activity: JsonObject): JsonObject | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Teams' own thumbs up / thumbs down under a message: the activity carries this channelData, Teams opens its feedback form
|
|
3
|
+
* and sends the answer back as a `message/submitAction` invoke (read by the feedback feature). `feedbackLoopEnabled: true`
|
|
4
|
+
* is the older spelling of the same.
|
|
5
|
+
*/
|
|
6
|
+
import { type JsonObject } from "../cards/json.js";
|
|
7
|
+
export declare const FEEDBACK_LOOP: JsonObject;
|
|
8
|
+
/** A copy of `activity` that asks Teams to show the thumbs under it (any other channelData is kept). */
|
|
9
|
+
export declare function withFeedbackLoop(activity: JsonObject): JsonObject;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Activity, type Fields } from "./schema.js";
|
|
2
|
+
/** The data of a card press, wherever the activity carries it; undefined when it carries none. */
|
|
3
|
+
export declare function cardDataOf(activity: Activity): Fields | undefined;
|
|
4
|
+
/** The kind of a card press (`data.primusclaw`), "" when the data names none. */
|
|
5
|
+
export declare function cardKindOf(activity: Activity): string;
|
|
6
|
+
/** The data of a press on a button of kind `kind`, if the activity is one. */
|
|
7
|
+
export declare function cardData(activity: Activity, kind: string): Fields | undefined;
|
|
8
|
+
type Reader = (activity: Activity) => Fields | undefined;
|
|
9
|
+
/** An Action.Execute invoke or an Action.Submit message of a decision card. */
|
|
10
|
+
export declare const cardAction: Reader;
|
|
11
|
+
/** A question card's Send button, with what the person chose and typed. */
|
|
12
|
+
export declare const answerAction: Reader;
|
|
13
|
+
/** A "Show here" button. */
|
|
14
|
+
export declare const showAction: Reader;
|
|
15
|
+
/** A repository card's "Use this repo" button. */
|
|
16
|
+
export declare const repoAction: Reader;
|
|
17
|
+
/** The changes card's "Create PR" button. */
|
|
18
|
+
export declare const createPrAction: Reader;
|
|
19
|
+
/** The feedback offer's "Yes, include it" / "No" buttons. */
|
|
20
|
+
export declare const feedbackAction: Reader;
|
|
21
|
+
/** One of the bot's own thumbs (the card under an answer on a phone). */
|
|
22
|
+
export declare const thumbAction: Reader;
|
|
23
|
+
/** The Send / Skip button under the comment question a thumbs-down on a phone opens. */
|
|
24
|
+
export declare const thumbNoteAction: Reader;
|
|
25
|
+
/** The "Report a problem" button under a message that went wrong. */
|
|
26
|
+
export declare const reportAction: Reader;
|
|
27
|
+
/** The "Connect" button of a group onboarding card. */
|
|
28
|
+
export declare const onboardAction: Reader;
|
|
29
|
+
/** One option button of a remote agent's permission card. */
|
|
30
|
+
export declare const remoteDecisionAction: Reader;
|
|
31
|
+
/** The Disconnect / Keep it buttons of a remote agent's disconnect card. */
|
|
32
|
+
export declare const remoteOffAction: Reader;
|
|
33
|
+
/** A button of the agents card or of the action row under a remote agent's answer. */
|
|
34
|
+
export declare const remoteAction: Reader;
|
|
35
|
+
/** Accept or Stop under a work item's card. */
|
|
36
|
+
export declare const workAction: Reader;
|
|
37
|
+
/** Accept or Dismiss under a suggestion of an observed group chat. */
|
|
38
|
+
export declare const observeAction: Reader;
|
|
39
|
+
/** Run or Cancel under a command the assistant put to the person. */
|
|
40
|
+
export declare const assistantActionClick: Reader;
|
|
41
|
+
/** A held write's card (allow or deny). */
|
|
42
|
+
export declare const assistantConfirmClick: Reader;
|
|
43
|
+
/** "Merge" / "Do not merge" on the card a high-risk merge sends to the reviewer. */
|
|
44
|
+
export declare const githubConfirmAction: Reader;
|
|
45
|
+
/** One of the two confirmation settings of the review mode card. */
|
|
46
|
+
export declare const githubModeAction: Reader;
|
|
47
|
+
/** "Not now" on the card offered beside a question about the person's own GitHub. */
|
|
48
|
+
export declare const githubConnectAction: Reader;
|
|
49
|
+
/** The "Act as me" confirmation card. */
|
|
50
|
+
export declare const bindAction: Reader;
|
|
51
|
+
/** A click on an Action.Execute button: the invoke the ingress answers with a placeholder card. */
|
|
52
|
+
export declare function isCardClick(activity: Activity): boolean;
|
|
53
|
+
/** The verb of a card click, for a log line (clipped: it comes from the client). */
|
|
54
|
+
export declare function cardVerb(activity: Activity): string;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who sent an activity, from which client, and where: the sender's directory identity, the tenant, the Teams client
|
|
3
|
+
* platform, and the kind and id of the conversation (the Python worker's `sender_of`, `tenant_of`, `client_platform`,
|
|
4
|
+
* `is_mobile`, `is_personal`, `is_group`, `conversation_id`).
|
|
5
|
+
*/
|
|
6
|
+
import type { ConversationKind } from "@primusclaw/personal-agent";
|
|
7
|
+
import { type Activity } from "./schema.js";
|
|
8
|
+
/** The Teams user behind an activity. */
|
|
9
|
+
export interface Sender {
|
|
10
|
+
/** The Entra object id. */
|
|
11
|
+
readonly aadId: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/** Only when the channel supplies it (never looked up); "" otherwise. */
|
|
14
|
+
readonly email: string;
|
|
15
|
+
}
|
|
16
|
+
/** The Teams user behind an activity, or undefined when it carries no Entra identity. */
|
|
17
|
+
export declare function senderOf(activity: Activity): Sender | undefined;
|
|
18
|
+
export declare function isPersonal(activity: Activity): boolean;
|
|
19
|
+
export declare function isGroup(activity: Activity): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The kind of the conversation for core: a 1:1 chat, a group chat, or anything else (a team's channel, or a
|
|
22
|
+
* conversation that does not say), which the worker does not serve.
|
|
23
|
+
*/
|
|
24
|
+
export declare function conversationKind(activity: Activity): ConversationKind;
|
|
25
|
+
export declare function conversationId(activity: Activity): string;
|
|
26
|
+
/** The Microsoft Entra tenant the conversation belongs to (a 1:1 conversation with a member needs it). */
|
|
27
|
+
export declare function tenantOf(activity: Activity): string;
|
|
28
|
+
/** What Teams' clientInfo says on a phone or a tablet (lower case). */
|
|
29
|
+
export declare const MOBILE_PLATFORMS: readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* The Teams client the person wrote from, as the activity's first `clientInfo` entity says it ("Windows", "Mac", "Web",
|
|
32
|
+
* "iOS", "Android"); "" when it carries none. Letters and digits only, at most 16: it comes from the client.
|
|
33
|
+
*/
|
|
34
|
+
export declare function clientPlatform(activity: Activity): string;
|
|
35
|
+
/** Teams on a phone or a tablet (its own thumbs under a bot's answer never reach the bot). */
|
|
36
|
+
export declare function isMobile(platform: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Reading an inbound Teams activity: its schema, the readers of its parts, and its mapping to core's events. */
|
|
2
|
+
export * from "./actions.js";
|
|
3
|
+
export * from "./identity.js";
|
|
4
|
+
export * from "./links.js";
|
|
5
|
+
export * from "./markup.js";
|
|
6
|
+
export * from "./mentions.js";
|
|
7
|
+
export * from "./quotes.js";
|
|
8
|
+
export * from "./schema.js";
|
|
9
|
+
export * from "./to-event.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hyperlinks behind a message's words (the Python worker's `links_of`, `_html_links`, `_card_links`). `text` is
|
|
3
|
+
* what the words look like on the screen: a link written with other words than its address shows only those words.
|
|
4
|
+
* Teams sends the address beside it: in the message's `text/html` attachment (`<a href>`), in a link preview card
|
|
5
|
+
* (`url`, an `openUrl` action's `value`), or in an entity's `url`. The links of a quote are the quote's (its Reply
|
|
6
|
+
* blockquote is left out here); a file's `downloadUrl` is a credential and is never read; a picture is not a link.
|
|
7
|
+
*/
|
|
8
|
+
import { type InboundLink } from "@primusclaw/personal-agent";
|
|
9
|
+
import { type Activity } from "./schema.js";
|
|
10
|
+
/** The most links that are added to a text. */
|
|
11
|
+
export declare const LINK_COUNT = 20;
|
|
12
|
+
/** A link: its address and the words shown for it ("" when there are none, or when they are the address). */
|
|
13
|
+
export interface Link {
|
|
14
|
+
readonly url: string;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
}
|
|
17
|
+
/** The `<a href>` of an HTML text, each with the words shown for it (tags inside the link dropped). */
|
|
18
|
+
export declare function htmlLinks(markup: string): Link[];
|
|
19
|
+
/**
|
|
20
|
+
* The web addresses in a card or an entity: a `url` / `href` / `contentUrl`, and the `value` of an `openUrl` action,
|
|
21
|
+
* each with the `title` of what holds it. Pictures are left out; the walk stops 8 levels down and at 50 items a list.
|
|
22
|
+
*/
|
|
23
|
+
export declare function cardLinks(node: unknown, title?: string, depth?: number): Link[];
|
|
24
|
+
/**
|
|
25
|
+
* The hyperlinks the person's own words carry, each address once, in the order found, at most LINK_COUNT: those of
|
|
26
|
+
* the message's HTML (its quote left out), of a link preview's card, and of an entity.
|
|
27
|
+
*/
|
|
28
|
+
export declare function linksOf(activity: Activity): Link[];
|
|
29
|
+
/** `linksOf` as core's links: the words shown are the title. */
|
|
30
|
+
export declare function inboundLinksOf(activity: Activity): InboundLink[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Activity } from "./schema.js";
|
|
2
|
+
/** `<at>` / `</at>`: the markup of a mention. */
|
|
3
|
+
export declare const AT_TAG: RegExp;
|
|
4
|
+
/** `raw` when it is an http(s) address (nothing else: no other scheme, no spaces, a sane length), else "". */
|
|
5
|
+
export declare function webUrl(raw: unknown): string;
|
|
6
|
+
/** One tag a finder matched: where it stands, whether it closes, and what stands between its name and its `>`. */
|
|
7
|
+
export interface TagMatch {
|
|
8
|
+
readonly start: number;
|
|
9
|
+
readonly end: number;
|
|
10
|
+
readonly closing: boolean;
|
|
11
|
+
readonly attrs: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Every `<name ...>` (and `</name ...>` when `closing`) of `text`, left to right and not overlapping: Python's
|
|
15
|
+
* `re.finditer(r"<(/?)(?:names)\b([^>]*)>", text, re.IGNORECASE)`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function findTags(text: string, names: readonly string[], closing: boolean): TagMatch[];
|
|
18
|
+
/** `text` with each of `tags` (from `findTags`) replaced by `by`. */
|
|
19
|
+
export declare function replaceTags(text: string, tags: readonly TagMatch[], by: string): string;
|
|
20
|
+
/** The itemtype of a Reply blockquote: the older way Teams marks a quote. */
|
|
21
|
+
export declare const REPLY_ITEMTYPE: RegExp;
|
|
22
|
+
/**
|
|
23
|
+
* (`markup` without its Reply blockquotes, [the attributes of each, what is inside it]). A blockquote inside a Reply
|
|
24
|
+
* blockquote belongs to it; a blockquote that is not a Reply stays where it is; one never closed runs to the end.
|
|
25
|
+
*/
|
|
26
|
+
export declare function cutReplies(markup: string): {
|
|
27
|
+
kept: string;
|
|
28
|
+
cut: [attrs: string, inner: string][];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* `text` as the person wrote it: without what Teams puts there for a quote (the `<quoted .../>` placeholder, and the
|
|
32
|
+
* Reply blockquote of a text that is HTML, with the paragraph tags that come with such a text).
|
|
33
|
+
*/
|
|
34
|
+
export declare function written(activity: Activity): string;
|
|
35
|
+
/**
|
|
36
|
+
* The message ids the `<quoted messageId="..."/>` placeholders of `text` name, in order: Python's
|
|
37
|
+
* `re.finditer(r"<quoted\b[^>]*?\bmessageId\s*=\s*[\"']?([^\"'\s/>]+)", text, re.IGNORECASE)`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function quotedIds(text: string): string[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an activity is for the bot, and the person's words: the bot's @mention, a targeted (private) message, a
|
|
3
|
+
* message that starts by naming the bot, the text without the mention markup, and the other people it @mentions (the
|
|
4
|
+
* Python worker's `is_mentioned`, `is_targeted`, `addressed_to_bot`, `message_text`, and the mention half of
|
|
5
|
+
* `marked_text`).
|
|
6
|
+
*/
|
|
7
|
+
import type { InboundMention } from "@primusclaw/personal-agent";
|
|
8
|
+
import { type Activity, type Fields } from "./schema.js";
|
|
9
|
+
/** The bot's display name where the caller gives none (the Python worker's `branding.BOT_NAME`). */
|
|
10
|
+
export declare const DEFAULT_BOT_NAME = "Clawy";
|
|
11
|
+
/** Whether `entity` is a mention of the bot (`botId` its id here; never when the id is unknown). */
|
|
12
|
+
export declare function mentionsBot(entity: Fields, botId: string): boolean;
|
|
13
|
+
/** True when the bot itself is @mentioned (a mention of another person does not count). */
|
|
14
|
+
export declare function isMentioned(activity: Activity): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* True for a targeted (private) message: in a group chat the person picked the bot under / and only the bot sees what
|
|
17
|
+
* they wrote. Teams marks it on the recipient.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isTargeted(activity: Activity): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* True when the message starts by naming the bot ("@Clawy ..."): in a 1:1 chat attached to a remote session, the way
|
|
22
|
+
* the person says these words are for the bot and not for the session.
|
|
23
|
+
*/
|
|
24
|
+
export declare function addressedToBot(activity: Activity, botName?: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The person's text without the bot's @mention markup and without what Teams adds for a quote: the words the commands
|
|
27
|
+
* are read from. With no recipient id every mention is removed (the 1:1 behaviour); in a group chat a mention of
|
|
28
|
+
* another person stays, minus its `<at>` tags, because it is part of what the person wrote.
|
|
29
|
+
*/
|
|
30
|
+
export declare function messageText(activity: Activity): string;
|
|
31
|
+
/**
|
|
32
|
+
* The people the message @mentions, the bot excluded, in the order of its entities: those whose mention stands in
|
|
33
|
+
* what the person wrote (not in a quote). `shown` is the mention as it stands in `messageText` (its `<at>` tags
|
|
34
|
+
* removed) and `offset` where (in code points), so core's `markedText` replaces the mention and not the same name
|
|
35
|
+
* typed elsewhere. With no recipient id there are none: `messageText` then removes every mention.
|
|
36
|
+
*/
|
|
37
|
+
export declare function mentionsOf(activity: Activity): InboundMention[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regular-expression pieces with the meaning Python's `re` gives them on a str, for the inbound readers' patterns.
|
|
3
|
+
* JavaScript differs in three places that matter here:
|
|
4
|
+
* - `\s`: Python's is `str.isspace()` (it has `\x1c`-`\x1f` and `\x85`, not U+FEFF): use `SPACE`;
|
|
5
|
+
* - `\w` and `\b`: Python's word characters are Unicode letters and digits and `_`: use `WORD` / `NOT_WORD_NEXT`;
|
|
6
|
+
* - `re.IGNORECASE` on an ASCII literal also matches U+0130 and U+0131 for i, U+212A (Kelvin) for k and U+017F for s, which
|
|
7
|
+
* JavaScript's `i` flag does or does not depending on `u`: spell such a literal with `caseless`, never with `i`.
|
|
8
|
+
*/
|
|
9
|
+
/** The characters Python's `\s` matches, as the inside of a character class. */
|
|
10
|
+
export declare const SPACE_CHARS = "\\t\\n\\v\\f\\r\\x1c-\\x20\\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
|
|
11
|
+
/** One character Python's `\s` matches. */
|
|
12
|
+
export declare const SPACE = "[\\t\\n\\v\\f\\r\\x1c-\\x20\\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]";
|
|
13
|
+
/** One character Python's `\w` matches (for patterns with the `u` flag). */
|
|
14
|
+
export declare const WORD = "[\\p{L}\\p{N}_]";
|
|
15
|
+
/** Python's `\b` after a word: the next character is not a word character (or there is none). */
|
|
16
|
+
export declare const NOT_WORD_NEXT = "(?![\\p{L}\\p{N}_])";
|
|
17
|
+
/**
|
|
18
|
+
* `literal` as a pattern source that matches it the way Python's `re.IGNORECASE` would (for a pattern with the `u`
|
|
19
|
+
* flag and without `i`). A non-ASCII letter matches its simple lower and upper case forms.
|
|
20
|
+
*/
|
|
21
|
+
export declare function caseless(literal: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Activity } from "./schema.js";
|
|
2
|
+
/** A quoted message as the activity describes it. */
|
|
3
|
+
export interface Quote {
|
|
4
|
+
readonly messageId: string;
|
|
5
|
+
readonly senderId: string;
|
|
6
|
+
readonly sender: string;
|
|
7
|
+
/** As Teams said it: epoch milliseconds, or a date. */
|
|
8
|
+
readonly time: string;
|
|
9
|
+
readonly text: string;
|
|
10
|
+
readonly deleted: boolean;
|
|
11
|
+
/** Where it was read from: for a log line, never the text. */
|
|
12
|
+
readonly source: "entity" | "html" | "placeholder";
|
|
13
|
+
}
|
|
14
|
+
/** The quote one Reply blockquote holds (`attrs`: the blockquote's own attributes; `inner`: what is inside it). */
|
|
15
|
+
export declare function htmlQuote(attrs: string, inner: string): Quote;
|
|
16
|
+
/** The Reply blockquotes of an activity: those of its text (when it is HTML), then of its `text/html` attachments. */
|
|
17
|
+
export declare function htmlQuotes(activity: Activity): Quote[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The messages an activity quotes (the Python worker's `quotes_of`, `_is_bot`, `_kinds` and the shape warning of
|
|
3
|
+
* `quote_block`). Teams says a quote in two ways and a client may use either: a `quotedReply` entity {messageId,
|
|
4
|
+
* senderId, senderName, preview, time, isReplyDeleted} with a `<quoted messageId="..."/>` placeholder in `text`, or a
|
|
5
|
+
* Reply blockquote (`quotes-html.ts`). Both are read; one quote said both ways is one quote. What a quote says never
|
|
6
|
+
* becomes part of the person's own text.
|
|
7
|
+
*/
|
|
8
|
+
import { type Logger } from "@primusclaw/personal-agent";
|
|
9
|
+
import { type Quote } from "./quotes-html.js";
|
|
10
|
+
import { type Activity, type Fields } from "./schema.js";
|
|
11
|
+
export type { Quote } from "./quotes-html.js";
|
|
12
|
+
/**
|
|
13
|
+
* The messages this one quotes, in the order Teams gave them: entities, then Reply blockquotes (one said both ways is
|
|
14
|
+
* one quote: the entity's words, the HTML's where the entity has none), then placeholders nothing else describes.
|
|
15
|
+
*/
|
|
16
|
+
export declare function quotesOf(activity: Activity): Quote[];
|
|
17
|
+
/**
|
|
18
|
+
* Was the quoted message written by the bot itself (`bot`: the activity's recipient)? By the Teams id (the part after
|
|
19
|
+
* the `28:` / `8:orgid:` prefix names the same account whichever way a client writes it); by the display name only when
|
|
20
|
+
* the quote has no id.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isBotQuote(quote: Quote, bot: Fields): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The `key` of each object in `items` (letters, digits and `/.-_`, clipped; at most ten): for a log line that says
|
|
25
|
+
* what shape came, never what it held.
|
|
26
|
+
*/
|
|
27
|
+
export declare function kindsOf(items: unknown, key: string): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Logs a `<quoted/>` placeholder that came with no quote data, by the activity's shape only (entity types, attachment
|
|
30
|
+
* types): what the client put there is never logged.
|
|
31
|
+
*/
|
|
32
|
+
export declare function logPlaceholderQuotes(activity: Activity, quotes: readonly Quote[], logger: Logger): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The inbound Bot Framework activity as the readers in this directory see it: a loose zod schema (every field the
|
|
3
|
+
* worker reads, and every other field kept as it came) and the small accessors the readers share.
|
|
4
|
+
*
|
|
5
|
+
* The schema is as tolerant as the Python worker's `activity.get(...) or {}` reads: a field may be missing or null, an
|
|
6
|
+
* entity or an attachment that is not an object is skipped by each reader. What the Python worker could not read at all
|
|
7
|
+
* (a `from` that is a string, `entities` that is not a list: it raised) is refused here as invalid input.
|
|
8
|
+
*/
|
|
9
|
+
import { type InvalidInput, type Result } from "@primusclaw/personal-agent";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
export declare const activitySchema: z.ZodObject<{
|
|
12
|
+
type: z.ZodOptional<z.ZodUnknown>;
|
|
13
|
+
id: z.ZodOptional<z.ZodUnknown>;
|
|
14
|
+
name: z.ZodOptional<z.ZodUnknown>;
|
|
15
|
+
text: z.ZodOptional<z.ZodUnknown>;
|
|
16
|
+
serviceUrl: z.ZodOptional<z.ZodUnknown>;
|
|
17
|
+
channelId: z.ZodOptional<z.ZodUnknown>;
|
|
18
|
+
locale: z.ZodOptional<z.ZodUnknown>;
|
|
19
|
+
from: z.ZodOptional<z.ZodNullable<z.ZodObject<{}, z.core.$loose>>>;
|
|
20
|
+
recipient: z.ZodOptional<z.ZodNullable<z.ZodObject<{}, z.core.$loose>>>;
|
|
21
|
+
conversation: z.ZodOptional<z.ZodNullable<z.ZodObject<{}, z.core.$loose>>>;
|
|
22
|
+
entities: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
|
|
23
|
+
attachments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnknown>>>;
|
|
24
|
+
replyToId: z.ZodOptional<z.ZodUnknown>;
|
|
25
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
26
|
+
channelData: z.ZodOptional<z.ZodUnknown>;
|
|
27
|
+
}, z.core.$loose>;
|
|
28
|
+
/** An inbound activity, validated. */
|
|
29
|
+
export type Activity = z.output<typeof activitySchema>;
|
|
30
|
+
/** A JSON object of an activity (an entity, an attachment, a card), read field by field. */
|
|
31
|
+
export type Fields = Readonly<Record<string, unknown>>;
|
|
32
|
+
/** Validates what the channel delivered. */
|
|
33
|
+
export declare function parseActivity(raw: unknown): Result<Activity, InvalidInput>;
|
|
34
|
+
export declare function isFields(value: unknown): value is Fields;
|
|
35
|
+
/** `activity.get(key) or {}` for one of its objects (`from`, `recipient`, `conversation`). */
|
|
36
|
+
export declare function partOf(activity: Activity, key: "from" | "recipient" | "conversation"): Fields;
|
|
37
|
+
/** The activity's entities that are objects. */
|
|
38
|
+
export declare function entitiesOf(activity: Activity): Fields[];
|
|
39
|
+
/** The activity's attachments that are objects. */
|
|
40
|
+
export declare function attachmentsOf(activity: Activity): Fields[];
|
|
41
|
+
/** The bot's own id in this conversation (`recipient.id`), "" when not said. */
|
|
42
|
+
export declare function botIdOf(activity: Activity): string;
|
|
43
|
+
/** Python's truthiness, for the `x or y` reads of a JSON value. */
|
|
44
|
+
export declare function truthy(value: unknown): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type InboundAction, type InboundMessage, type InboundVote, type InvalidInput, type Logger, type Result } from "@primusclaw/personal-agent";
|
|
2
|
+
import { type Activity } from "./schema.js";
|
|
3
|
+
/** The events a Teams activity can be. */
|
|
4
|
+
export type TeamsInboundEvent = InboundMessage | InboundAction | InboundVote;
|
|
5
|
+
/** The activity has no Entra identity behind it: nobody to act for. */
|
|
6
|
+
export interface NoSender {
|
|
7
|
+
readonly kind: "no_sender";
|
|
8
|
+
}
|
|
9
|
+
export interface ToEventOptions {
|
|
10
|
+
/** The bot's display name, for "@<name> ..." (default "Clawy"). */
|
|
11
|
+
readonly botName?: string;
|
|
12
|
+
readonly logger?: Logger;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The conversation reference the outbound side posts back with (the Python worker's `reference_of`), keys in its
|
|
16
|
+
* order; a field the activity lacks is null, as Python stored it. Stored for proactive messages, so it stays
|
|
17
|
+
* byte-for-byte what the Python worker stored.
|
|
18
|
+
*/
|
|
19
|
+
export declare function wireReferenceOf(activity: Activity): Record<string, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* What core acts on in `raw`: a message, a card press, or undefined for an activity that is neither. Refused when
|
|
22
|
+
* `raw` is not an activity, or when no Entra identity is behind it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function toInboundEvent(raw: unknown, options?: ToEventOptions): Result<TeamsInboundEvent | undefined, InvalidInput | NoSender>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type JsonObject } from "../cards/json.js";
|
|
2
|
+
import type { Operation, TeamsEnvelope } from "../outbound/outbox.js";
|
|
3
|
+
export declare const TYPING: JsonObject;
|
|
4
|
+
/** A plain message (markdown). */
|
|
5
|
+
export declare function textActivity(text: string): JsonObject;
|
|
6
|
+
/** The conversation reference the outbound side (queue relay or Bot Connector) needs to post back into `activity`'s chat. */
|
|
7
|
+
export declare function referenceOf(activity: JsonObject): JsonObject;
|
|
8
|
+
/**
|
|
9
|
+
* A message activity in the conversation `reference` points at (the inverse of `referenceOf`), for work done for a person
|
|
10
|
+
* without a message of theirs in hand. It carries no text.
|
|
11
|
+
*/
|
|
12
|
+
export declare function activityOfReference(reference: JsonObject, activityId: string): JsonObject;
|
|
13
|
+
export interface EnvelopeOptions {
|
|
14
|
+
readonly activityId?: string | undefined;
|
|
15
|
+
readonly ack?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** One outbound envelope: `{operation, reference, activity, [activity_id], [ack]}`. */
|
|
18
|
+
export declare function envelope(operation: Operation, reference: JsonObject, activity: JsonObject, options?: EnvelopeOptions): TeamsEnvelope;
|
|
19
|
+
/** Remove the message `activityId`. Every envelope carries an activity, so a delete carries an empty message. */
|
|
20
|
+
export declare function deleteEnvelope(reference: JsonObject, activityId: string): TeamsEnvelope;
|
|
21
|
+
/**
|
|
22
|
+
* A copy of `activity` that starts by @mentioning this person (Teams notifies them): `<at>name</at>` in front of the text,
|
|
23
|
+
* and the mention entity. The activity itself when the id or the name is missing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withMention(activity: JsonObject, teamsId: string, name: string): JsonObject;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential masking of an outbound activity for a group chat: a copy with every credential shape masked in its text and
|
|
3
|
+
* in its cards' text; when anything was masked, one line says so (after the text, or as a last card TextBlock). The masking
|
|
4
|
+
* rules are core's (`redactText`); this walks a Teams activity with them. A Teams `Masker` is made of the two.
|
|
5
|
+
*/
|
|
6
|
+
import { type JsonObject } from "../cards/json.js";
|
|
7
|
+
import type { Masker } from "../messenger/masker.js";
|
|
8
|
+
/** A text masker: `text` with every credential shape masked, and whether anything was. */
|
|
9
|
+
export type RedactText = (text: string) => {
|
|
10
|
+
readonly text: string;
|
|
11
|
+
readonly masked: boolean;
|
|
12
|
+
};
|
|
13
|
+
/** A copy of `activity` with credential shapes masked (the activity itself when nothing was). */
|
|
14
|
+
export declare function redactActivity(activity: JsonObject, redact: RedactText, note: string): JsonObject;
|
|
15
|
+
/** The Teams masker of a group chat, from core's text masking rules and the line that says something was masked. */
|
|
16
|
+
export declare function teamsMasker(redact: RedactText, note: string): Masker;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stored Teams conversation reference back as core's `ConversationRef`. The store keeps the reference exactly as the
|
|
3
|
+
* Python worker wrote it (`activity.reference_of`: serviceUrl, conversation, bot, user, activityId, [channelId], [locale];
|
|
4
|
+
* or the 1:1 reference made after opening a chat with someone, without an activityId); the reference stays the `wire` as
|
|
5
|
+
* it is, unchanged, so it can be stored again byte for byte.
|
|
6
|
+
*/
|
|
7
|
+
import type { ConversationRef, JsonObject } from "@primusclaw/personal-agent";
|
|
8
|
+
/** The reference `stored` names; undefined when it is not one (no serviceUrl, no conversation id). Never throws. */
|
|
9
|
+
export declare function restoreConversationRef(stored: JsonObject): ConversationRef | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** The activities of a Teams stream (Bot Framework REST "Stream agent messages"): its numbered requests and its final message. */
|
|
2
|
+
import { type JsonObject } from "../cards/json.js";
|
|
3
|
+
export declare const STREAM_ENTITY_TYPE = "streaminfo";
|
|
4
|
+
export type StreamKind = "informative" | "streaming";
|
|
5
|
+
/**
|
|
6
|
+
* One request of a Teams stream: an informative update or the streamed text so far, a typing activity in reply to the
|
|
7
|
+
* person's message, numbered; the first has no stream id yet.
|
|
8
|
+
*/
|
|
9
|
+
export declare function streamActivity(kind: StreamKind, text: string, replyTo: string, sequence: number, streamId?: string): JsonObject;
|
|
10
|
+
/**
|
|
11
|
+
* `activity` (a message) as the request that closes the stream `streamId`: the final message, which Teams keeps. Its
|
|
12
|
+
* stream entity goes first, without a sequence number; the activity's own entities (the root entity) follow.
|
|
13
|
+
*/
|
|
14
|
+
export declare function streamFinal(activity: JsonObject, replyTo: string, streamId: string): JsonObject;
|
|
15
|
+
/** The stream entity of an activity, if it has one (what a recording connector reads to apply Teams' stream rules). */
|
|
16
|
+
export declare function streamInfo(activity: JsonObject): JsonObject | undefined;
|
|
@@ -0,0 +1,42 @@
|
|
|
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: "remoteAsk";
|
|
28
|
+
model: remoteView.RemoteAskView;
|
|
29
|
+
};
|
|
30
|
+
fallbackText: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export interface AssistantInputs {
|
|
34
|
+
readonly style: Style;
|
|
35
|
+
readonly integrations: Integrations;
|
|
36
|
+
/** A review the assistant handed back (`review_for_other`): to the review service, "dropped" without it. */
|
|
37
|
+
readonly reviewHandoff: (userId: string, event: Readonly<Record<string, unknown>>) => "delivered" | "dropped";
|
|
38
|
+
/** NOTIFY_WEBHOOK_URL ("" off). */
|
|
39
|
+
readonly notifyUrl: string;
|
|
40
|
+
readonly hooks: RouterHooks;
|
|
41
|
+
}
|
|
42
|
+
export declare function assistantParts(base: AssemblyBase, inputs: AssistantInputs): AssistantParts;
|
|
@@ -0,0 +1,49 @@
|
|
|
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, 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
|
+
}
|
|
45
|
+
type SenderOf = Parameters<import("@primusclaw/personal-agent").Router["chat"]>[0];
|
|
46
|
+
type ConversationOf = Parameters<import("@primusclaw/personal-agent").Router["chat"]>[1];
|
|
47
|
+
/** The Teams style's reading of a conversation kind (`style.streams_in`'s conversation types). */
|
|
48
|
+
export declare function conversationTypeOf(kind: string): string;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
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 } 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): ProactiveParts;
|
|
19
|
+
/** What the router reads of quiet hours and /pause (`muted` as a word or null, `release` on /resume). */
|
|
20
|
+
export declare function proactiveHold(parts: ProactiveParts): ProactiveHold;
|
|
21
|
+
/**
|
|
22
|
+
* What the remote agents' follower reads of it. Python's follower hands Proactive its chat key as the person (`self.aad_id`
|
|
23
|
+
* 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
|
|
24
|
+
* unchanged; the event id of a held message is a fresh uuid4 hex, as Python's `hold_remote` makes it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function followReach(parts: ProactiveParts, base: Pick<AssemblyBase, "random">): FollowReach;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DirectChat, FollowReach, PublicErrors } from "@primusclaw/personal-agent";
|
|
2
|
+
import { Guardrails, RemoteAgents } from "@primusclaw/personal-agent";
|
|
3
|
+
import type { AssemblyBase, RouterHooks } from "./features-base.js";
|
|
4
|
+
import type { FeatureSwitches } from "./features-switches.js";
|
|
5
|
+
export interface RemoteInputs {
|
|
6
|
+
readonly switches: FeatureSwitches;
|
|
7
|
+
readonly guard: Guardrails;
|
|
8
|
+
readonly reach: FollowReach;
|
|
9
|
+
readonly errors: PublicErrors;
|
|
10
|
+
readonly directChat: DirectChat;
|
|
11
|
+
readonly hooks: RouterHooks;
|
|
12
|
+
}
|
|
13
|
+
export declare function remoteAgents(base: AssemblyBase, inputs: RemoteInputs): RemoteAgents;
|