@sleep2agi/agent-network 2.3.0-preview.3 → 2.3.0-preview.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.
- package/README.md +1 -1
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +1 -1
- package/dist/bin/goal-wake-log-render.d.ts +31 -0
- package/dist/src/client.js +1 -1
- package/dist/src/environ-alias.d.ts +14 -0
- package/dist/src/im/feishu/adapter.d.ts +106 -1
- package/dist/src/im/feishu/bridge.d.ts +7 -0
- package/dist/src/im/feishu/config.d.ts +31 -0
- package/dist/src/im/feishu/hub-upload.d.ts +88 -0
- package/dist/src/im/feishu/markdown-image-renderer.d.ts +61 -0
- package/dist/src/im/feishu/outbound-marker.d.ts +140 -0
- package/dist/src/im/feishu/outbound-paths.d.ts +50 -0
- package/dist/src/im/feishu/outbound-route.d.ts +62 -0
- package/dist/src/im/feishu/worker.js +390 -16
- package/dist/src/im/types.d.ts +38 -1
- package/dist/src/node-server.js +1 -1
- package/dist/src/normalize-runtime.d.ts +1 -1
- package/dist/src/opencode-pin.d.ts +41 -0
- package/dist/src/opencode-preset.d.ts +43 -0
- package/dist/src/project-key.d.ts +1 -0
- package/package.json +7 -4
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC-020 §16.1 — feishu outbound route decision (pure helper).
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for the `adapter.send` decision tree that
|
|
5
|
+
* picks among text / interactive card / image (rendered PNG) / file /
|
|
6
|
+
* imagePath outputs. Extracted into a pure module so the production
|
|
7
|
+
* call site AND the unit tests can bind the same function — previously
|
|
8
|
+
* the test mirrored the decision tree in a sibling `pickRoute` helper,
|
|
9
|
+
* which would drift silently if the production tree changed.
|
|
10
|
+
*
|
|
11
|
+
* Inputs are the minimal data the decision needs:
|
|
12
|
+
*
|
|
13
|
+
* - `text` / `imagePath` / `files` — payload from `NormalizedIMMessage`
|
|
14
|
+
* - `forceTextOnly` — caption-mode hint (RFC-020 §15.2)
|
|
15
|
+
* - `mode` — channel-config `outboundRender` (`"plain"` / `"card"` /
|
|
16
|
+
* `"auto"`, RFC-020 §16)
|
|
17
|
+
*
|
|
18
|
+
* Outputs the chosen `route` plus a short `reason` string for log /
|
|
19
|
+
* debug. The CALLER (adapter.send) actually performs the upload /
|
|
20
|
+
* render side-effects keyed on the route — this function does no I/O.
|
|
21
|
+
*
|
|
22
|
+
* Behavior contract (mirrors adapter.send line-for-line, locked by
|
|
23
|
+
* `feishu-outbound-render-mode.test.ts`):
|
|
24
|
+
*
|
|
25
|
+
* 1. `imagePath` set → `image_upload`
|
|
26
|
+
* 2. `files[0].path` set → `file_upload`
|
|
27
|
+
* 3. `forceTextOnly` true → `text`
|
|
28
|
+
* 4. mode "plain" → `text` (always)
|
|
29
|
+
* 5. mode "card" → `card_short_md` iff `looksLikeMarkdown(text)` AND
|
|
30
|
+
* NOT `shouldRenderAsImage(text)`; else `text`
|
|
31
|
+
* 6. mode "auto" → `image_render` iff `shouldRenderAsImage(text)`;
|
|
32
|
+
* else `card_short_md` iff `looksLikeMarkdown(text)`; else `text`
|
|
33
|
+
* 7. unknown mode (defensive default-default) → `text`
|
|
34
|
+
*
|
|
35
|
+
* The production switch in adapter.send may add the actual upload /
|
|
36
|
+
* render / lark API calls keyed on the route, but the route itself
|
|
37
|
+
* is decided HERE. To change the decision, change this file.
|
|
38
|
+
*/
|
|
39
|
+
export type OutboundRoute = "image_upload" | "file_upload" | "text" | "card_short_md" | "image_render";
|
|
40
|
+
export interface RouteInput {
|
|
41
|
+
text?: string;
|
|
42
|
+
imagePath?: string;
|
|
43
|
+
files?: {
|
|
44
|
+
name: string;
|
|
45
|
+
path?: string;
|
|
46
|
+
}[];
|
|
47
|
+
forceTextOnly?: boolean;
|
|
48
|
+
/** `outboundRender` from the channel config. Defaults to "plain" when
|
|
49
|
+
* absent so a caller that doesn't read the config still gets the
|
|
50
|
+
* "Vincent default" behavior. */
|
|
51
|
+
mode?: "plain" | "card" | "auto";
|
|
52
|
+
}
|
|
53
|
+
export interface RouteDecision {
|
|
54
|
+
route: OutboundRoute;
|
|
55
|
+
reason: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Decide the outbound route for a `NormalizedIMMessage` (or a subset
|
|
59
|
+
* of its fields). Pure — no I/O, no SDK calls; safe to call from tests
|
|
60
|
+
* directly.
|
|
61
|
+
*/
|
|
62
|
+
export declare function resolveOutboundRoute(input: RouteInput): RouteDecision;
|