@tangle-network/agent-app 0.45.29 → 0.45.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
+ import * as react from 'react';
1
2
  import { ReactNode } from 'react';
2
3
  import { F as FileMention } from './wire-DOZ-O6hD.js';
4
+ import { Harness } from './harness/index.js';
5
+ import { CatalogModel } from './catalog/index.js';
3
6
 
4
7
  /**
5
8
  * `useFileMentions` — the glue a host passes straight into `AgentComposer`'s
@@ -95,4 +98,32 @@ interface UseFileMentionsResult {
95
98
  /** Resolve and manage file mention data with configurable fetching and state handling */
96
99
  declare function useFileMentions(options: UseFileMentionsOptions): UseFileMentionsResult;
97
100
 
98
- export { type ComposerMentionProp as C, DEFAULT_MENTION_EMPTY_TEXT as D, INDEX_REFRESH_AFTER_MS as I, type MentionItem as M, type UseFileMentionsResult as U, DEFAULT_MENTION_LIMIT as a, type UseFileMentionsOptions as b, rankFileMentions as r, useFileMentions as u };
101
+ interface AgentSessionControlsProps {
102
+ /** Catalog models — canonical provider-prefixed ids. */
103
+ models: CatalogModel[];
104
+ modelsLoading?: boolean;
105
+ /** Selected canonical model id. */
106
+ model: string;
107
+ onModelChange(modelId: string): void;
108
+ /** Current harness; harness↔model coherence is enforced on every change. */
109
+ harness: Harness;
110
+ onHarnessChange(harness: Harness): void;
111
+ /** Harnesses to offer; defaults to the labeled set. */
112
+ availableHarnesses?: ReadonlyArray<Harness>;
113
+ /** Reasoning-effort value + setter. Shown only when the selected model
114
+ * `supportsReasoning`, matching `EffortPicker`'s guidance. */
115
+ effort: string;
116
+ onEffortChange(effort: string): void;
117
+ /**
118
+ * `inline` (default): model, harness, effort side by side — the prior
119
+ * behavior. `compact`: model inline, harness + effort behind a gear popover.
120
+ */
121
+ layout?: 'inline' | 'compact';
122
+ /** Hide the harness control entirely (single-harness products). */
123
+ showHarness?: boolean;
124
+ renderProviderBadge?: (provider: string) => ReactNode;
125
+ className?: string;
126
+ }
127
+ declare function AgentSessionControls(props: AgentSessionControlsProps): react.JSX.Element;
128
+
129
+ export { type AgentSessionControlsProps as A, type ComposerMentionProp as C, DEFAULT_MENTION_EMPTY_TEXT as D, INDEX_REFRESH_AFTER_MS as I, type MentionItem as M, type UseFileMentionsResult as U, AgentSessionControls as a, DEFAULT_MENTION_LIMIT as b, type UseFileMentionsOptions as c, rankFileMentions as r, useFileMentions as u };
@@ -0,0 +1,178 @@
1
+ /**
2
+ * `/alerting` — post an operational alert to Slack, and say honestly when it
3
+ * did not arrive.
4
+ *
5
+ * WHY THIS EXISTS: on 2026-08-06 an audit of every Slack credential the org
6
+ * held found three of four dead — the fleet incoming webhook 404ing
7
+ * (`no_service`), a second company webhook likewise, and the bot token
8
+ * answering `account_inactive`. One ops webhook was still live. Nobody knew
9
+ * which was which until each was tested by hand, and that is the actual
10
+ * problem: the credentials were indistinguishable from where the code stood.
11
+ *
12
+ * This failure has already been paid for once, with numbers: in
13
+ * `agent-dev-container`, a revoked webhook let the CI healthcheck sit dead for
14
+ * 18 days — 2,567 consecutive failures, 27 successes, zero alerts — because
15
+ * fifteen call sites across six workflows posted with no body inspection and
16
+ * then asserted delivery. That repo fixed the reporting (its `post-slack.sh`
17
+ * confirms 2xx AND Slack's literal `ok` body, and fails closed otherwise) and
18
+ * that half of the lesson is theirs, adopted here.
19
+ *
20
+ * What their fix cannot do, and this module can, is answer the question BEFORE
21
+ * an alert needs to fire. A fail-closed post still only discovers a dead
22
+ * credential at the moment a page is lost. That is the second half.
23
+ *
24
+ * Two design consequences, and they are the whole module:
25
+ *
26
+ * 1. **A bot token and `chat.postMessage` is the preferred transport; an
27
+ * incoming webhook is supported because one is usually what you already
28
+ * have.** A token reaches every channel (a webhook is bolted to one), is
29
+ * revocable and rotatable in place, and — the part that matters — is
30
+ * VERIFIABLE: `auth.test` answers whether the credential is alive without
31
+ * posting anything, which is what lets `/preflight` fail a deploy on a dead
32
+ * alerting channel instead of discovering it during an incident. A webhook
33
+ * can only be tested by posting to it, which is why the three dead
34
+ * credentials above went unnoticed. A token is never fallen back FROM: if
35
+ * one is configured and dead, delivering over a webhook instead would hide
36
+ * the very condition worth reporting.
37
+ *
38
+ * 2. **Slack answers `ok:false` under HTTP 200.** `invalid_auth`,
39
+ * `channel_not_found` and `not_in_channel` all arrive as a successful
40
+ * response with a failure inside it, so a status check reads a dead channel
41
+ * as a delivered page. The body is always parsed, and the outcome
42
+ * distinguishes a MISSING credential (configuration absent — not an
43
+ * incident) from a DEAD one (the alerting channel itself is broken — the
44
+ * loudest thing this module can report). A summary that calls those two the
45
+ * same thing is the defect wearing a different hat.
46
+ *
47
+ * The caller decides what to do with a non-delivery; this module never throws
48
+ * on one, because an alerting path that can take down the thing it reports on
49
+ * is worse than the outage it was watching for. It is also never the only
50
+ * channel: a durable record (an issue, an audit row) is the caller's job, and
51
+ * that is what survives the credential going dead again.
52
+ *
53
+ * Server-only: holds a bot token. This subpath must never reach a browser
54
+ * bundle.
55
+ */
56
+ /**
57
+ * Why an alert did not reach Slack. The split is by what a human must DO about
58
+ * it, since that is the only distinction a caller can act on.
59
+ */
60
+ type SlackFailureReason =
61
+ /** No token or no channel configured. Configuration is absent, nothing is broken. */
62
+ 'not-configured'
63
+ /**
64
+ * The token is dead — revoked, or its app removed from the workspace. No
65
+ * alert will EVER arrive until a human mints a new one. This is itself an
66
+ * incident and the caller should escalate it on a channel that does not
67
+ * depend on Slack.
68
+ */
69
+ | 'credential'
70
+ /**
71
+ * The credential is alive but cannot post HERE: the channel is wrong,
72
+ * archived, or the bot was never invited to it. One human action fixes it.
73
+ */
74
+ | 'channel'
75
+ /** Slack asked us to slow down. Transient; the alert is worth retrying. */
76
+ | 'rate-limited'
77
+ /** The request never got an answer — network, DNS, timeout. Transient. */
78
+ | 'transport'
79
+ /** Slack refused for some other reason; `detail` carries its error code. */
80
+ | 'api';
81
+ /** An alert that did not arrive, and why. Named because the classifiers only ever produce this half. */
82
+ interface SlackAlertFailure {
83
+ delivered: false;
84
+ reason: SlackFailureReason;
85
+ /** One line naming what is wrong and what fixes it. Safe to log; carries no token. */
86
+ detail: string;
87
+ }
88
+ /** What one `postSlackAlert` call did. Never a bare boolean — the caller pages differently per reason. */
89
+ type SlackAlertOutcome = {
90
+ delivered: true;
91
+ /** The channel id Slack resolved (not necessarily the name that was passed). */
92
+ channel: string;
93
+ /** Slack's message timestamp — the message's identity, for a later thread reply. */
94
+ ts: string;
95
+ } | SlackAlertFailure;
96
+ /** Define configuration options for posting an alert message to a Slack channel */
97
+ interface SlackAlertOptions {
98
+ /**
99
+ * Slack bot token (`xoxb-…`) with `chat:write`. The PREFERRED transport,
100
+ * because it is the only one whose liveness can be checked before an alert
101
+ * needs it. An empty or absent value is `not-configured`, never an error — a
102
+ * product that has not adopted Slack yet must not fail its alerting path.
103
+ */
104
+ token?: string | undefined;
105
+ /**
106
+ * Channel to post to: a name (`#infra-alerts`) or an id (`C01234567`). The
107
+ * bot must be a member; Slack answers `not_in_channel` otherwise. Required
108
+ * with `token`, meaningless with `webhookUrl` (a webhook carries its own
109
+ * channel, fixed when it was created).
110
+ */
111
+ channel?: string | undefined;
112
+ /**
113
+ * Slack incoming-webhook URL, used only when no `token` is configured.
114
+ *
115
+ * It works and it needs no setup, which is why it is supported — but it
116
+ * cannot be verified without posting, cannot be pointed at a second channel,
117
+ * and gives back an error token instead of a code. Two of the three webhooks
118
+ * this org has held were found revoked. Treat it as the transport you have,
119
+ * not the one you want.
120
+ *
121
+ * When a `token` is also configured this is IGNORED rather than used as a
122
+ * fallback: a dead token must surface as the incident it is, and quietly
123
+ * succeeding over a second transport is how the last outage stayed invisible.
124
+ */
125
+ webhookUrl?: string | undefined;
126
+ /** Message body as Slack mrkdwn. Newlines are preserved. */
127
+ text: string;
128
+ /**
129
+ * Attempts for a TRANSIENT failure (429 / 5xx / transport). Default 3. A
130
+ * dead credential or a wrong channel is never retried — the answer will not
131
+ * change, and retrying an auth failure is how a token gets rate-limited.
132
+ */
133
+ attempts?: number;
134
+ /** Per-request deadline. Default 10s. */
135
+ timeoutMs?: number;
136
+ /** Injection seam for tests; defaults to global `fetch`. */
137
+ fetchImpl?: typeof fetch;
138
+ /** Injection seam for tests; defaults to a real delay between retries. */
139
+ sleepImpl?: (ms: number) => Promise<void>;
140
+ }
141
+ /**
142
+ * Post one alert to a Slack channel.
143
+ *
144
+ * Never throws and never retries a failure whose answer cannot change. The
145
+ * returned outcome is the whole result — a caller that ignores it has an
146
+ * alerting path it cannot prove works, which is the failure this module was
147
+ * written for.
148
+ */
149
+ declare function postSlackAlert(options: SlackAlertOptions): Promise<SlackAlertOutcome>;
150
+ /** Define configuration options for verifying that a Slack bot token is live */
151
+ interface SlackCredentialCheckOptions {
152
+ token: string | undefined;
153
+ /** Per-request deadline. Default 10s. */
154
+ timeoutMs?: number;
155
+ /** Injection seam for tests; defaults to global `fetch`. */
156
+ fetchImpl?: typeof fetch;
157
+ }
158
+ /** What `checkSlackCredential` concluded. `team`/`botId` are present only when live. */
159
+ type SlackCredentialVerdict = {
160
+ live: true;
161
+ team: string;
162
+ botId: string;
163
+ } | {
164
+ live: false;
165
+ reason: SlackFailureReason;
166
+ detail: string;
167
+ };
168
+ /**
169
+ * Ask Slack whether the bot token is alive, WITHOUT posting anything.
170
+ *
171
+ * This is the check that was missing. An incoming webhook offers no equivalent
172
+ * — the only way to test one is to post to it — which is how a revoked webhook
173
+ * sat in a repo secret for months looking configured. Wire it into `/preflight`
174
+ * so a dead alerting channel fails a deploy rather than an incident.
175
+ */
176
+ declare function checkSlackCredential(options: SlackCredentialCheckOptions): Promise<SlackCredentialVerdict>;
177
+
178
+ export { type SlackAlertFailure, type SlackAlertOptions, type SlackAlertOutcome, type SlackCredentialCheckOptions, type SlackCredentialVerdict, type SlackFailureReason, checkSlackCredential, postSlackAlert };
@@ -0,0 +1,9 @@
1
+ import {
2
+ checkSlackCredential,
3
+ postSlackAlert
4
+ } from "../chunk-COP2K4LF.js";
5
+ export {
6
+ checkSlackCredential,
7
+ postSlackAlert
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -7,7 +7,9 @@ import '../plans/index.js';
7
7
  import '../parts-BqIHMdyu.js';
8
8
  import '../types-CCeYywdS.js';
9
9
  import '../wire-DOZ-O6hD.js';
10
- import '../use-file-mentions-CZ-Ua_sb.js';
10
+ import '../agent-session-controls-BwImzYKC.js';
11
+ import '../harness/index.js';
12
+ import '../catalog/index.js';
11
13
  import '../agent-activity-C8ZG0F0M.js';
12
14
  import '../flow-types-CJxEmaRy.js';
13
15
  import '../queue-VTBA5ONX.js';
@@ -16,8 +18,6 @@ import '../billing-BibxgALe.js';
16
18
  import '../billing/index.js';
17
19
  import '../session-shell/index.js';
18
20
  import '../web-react/async/index.js';
19
- import '../catalog/index.js';
20
- import '../harness/index.js';
21
21
  import '../attachment-validation-BfJDBU1g.js';
22
22
  import '../stream-normalizer-DKRxyVlZ.js';
23
23
 
@@ -1,17 +1,18 @@
1
- import {
2
- AsyncView
3
- } from "../chunk-YIQHOAHN.js";
4
1
  import {
5
2
  ChatComposer,
6
- ChatMessages,
7
- ModelPicker,
8
- ProviderLogo
9
- } from "../chunk-3I27SDU3.js";
3
+ ChatMessages
4
+ } from "../chunk-IFYJDX3J.js";
10
5
  import "../chunk-FBVLEGEG.js";
11
6
  import "../chunk-HZ4WCA37.js";
12
7
  import "../chunk-GEYACSFW.js";
13
- import "../chunk-E4DHYENH.js";
8
+ import {
9
+ ModelPicker,
10
+ ProviderLogo
11
+ } from "../chunk-L7FHRORY.js";
14
12
  import "../chunk-BATKJP3P.js";
13
+ import {
14
+ AsyncView
15
+ } from "../chunk-YIQHOAHN.js";
15
16
  import "../chunk-PC2WYTK7.js";
16
17
  import "../chunk-QY4BRKRJ.js";
17
18
  import "../chunk-CCVG2TL6.js";