@mininglamp-oss/octo-runtime 1.1.6 → 1.1.7
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/apps/cli/dist/build-info.json +2 -2
- package/dist/public/dsh.d.ts +1 -1
- package/dist/public/dsh.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +17 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +20 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +32 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +16 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +32 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-IW62UM3C.js → chunk-CFKMMCO6.js} +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-FWAPYRV2.js → chunk-LO34KB7D.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-3GXX5VD5.js → chunk-V5W6ZTYC.js} +14 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +4 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +17 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +8 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +4 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +10 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/compatibility.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/compatibility.js +12 -40
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +22 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +422 -135
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +6 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +9 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +18 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +7 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.d.ts +20 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +24 -24
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/runner.js +102 -52
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/windows-task.js +8 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +4 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-input.js +9 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.d.ts +17 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/context-gap.js +22 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/history-context.js +27 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +444 -226
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.d.ts +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/rules-context.js +42 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/session-store.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.d.ts +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/stable-context.js +28 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +16 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.d.ts +4 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifact-policy.js +12 -9
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/artifacts.js +7 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.d.ts +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.js +36 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/scheduler.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.d.ts +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/dispatcher.js +36 -22
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +14 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/lifecycle/configuration.js +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/run-projector.js +265 -38
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/cards.js +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/client.js +19 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/conversations.js +4 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.d.ts +0 -12
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/errors.js +5 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/files.js +8 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/api/messages.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.js +27 -15
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +17 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +217 -50
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.js +2 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.js +41 -12
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.d.ts +2 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.js +53 -82
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.d.ts +12 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-content.js +133 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.d.ts +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/history-messages.js +76 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.js +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.d.ts +16 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-identities.js +74 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-time.js +19 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/message-trigger.js +90 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/retry-after.js +60 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +20 -8
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +10 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +14 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/transport/channel.js +2 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.js +11 -4
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +8 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +138 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
- package/node_modules/iconv-lite/encodings/index.js +23 -0
- package/node_modules/iconv-lite/encodings/internal.js +218 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +180 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +187 -0
- package/node_modules/iconv-lite/encodings/utf32.js +314 -0
- package/node_modules/iconv-lite/encodings/utf7.js +283 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +48 -0
- package/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/node_modules/iconv-lite/lib/index.d.ts +129 -0
- package/node_modules/iconv-lite/lib/index.js +182 -0
- package/node_modules/iconv-lite/lib/streams.js +105 -0
- package/node_modules/iconv-lite/package.json +70 -0
- package/node_modules/iconv-lite/types/encodings.d.ts +425 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/semver/LICENSE +15 -0
- package/node_modules/semver/README.md +680 -0
- package/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/semver/classes/index.js +7 -0
- package/node_modules/semver/classes/range.js +577 -0
- package/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/semver/functions/major.js +5 -0
- package/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/semver/index.js +93 -0
- package/node_modules/semver/internal/constants.js +37 -0
- package/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/semver/internal/re.js +223 -0
- package/node_modules/semver/package.json +78 -0
- package/node_modules/semver/preload.js +4 -0
- package/node_modules/semver/range.bnf +17 -0
- package/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/semver/ranges/valid.js +13 -0
- package/package.json +33 -27
- package/packages/octo-runtime-extra-channel-gateway/config-schema.json +8 -1
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +43 -1
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.d.ts
CHANGED
|
@@ -5,15 +5,11 @@ import { type ContextItem } from "@mininglamp-oss/octo-runtime-protocol";
|
|
|
5
5
|
import type { ScopedOctoBotConfig } from "../contracts.js";
|
|
6
6
|
import type { ImMessage } from "./wukong.js";
|
|
7
7
|
import { type ImGapPlan } from "../application/context-gap.js";
|
|
8
|
+
import { type MessageIdentityCache } from "./message-identities.js";
|
|
8
9
|
export declare function build_im_contexts(config: ScopedOctoBotConfig, message: ImMessage, botToken: string, signal: AbortSignal, options?: {
|
|
9
10
|
initialSession: boolean;
|
|
10
|
-
mentionGuidance?: boolean;
|
|
11
11
|
configuredItems?: readonly ContextItem[];
|
|
12
12
|
historyGap?: ImGapPlan;
|
|
13
|
+
identityCache?: MessageIdentityCache;
|
|
13
14
|
onHistoryGapPrepared?(plan: ImGapPlan): void;
|
|
14
15
|
}): Promise<ContextItem[]>;
|
|
15
|
-
export declare function historyText(entries: Array<{
|
|
16
|
-
from_uid: string;
|
|
17
|
-
content: string;
|
|
18
|
-
type?: number;
|
|
19
|
-
}>): string;
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/contexts.js
CHANGED
|
@@ -6,14 +6,18 @@ import { resourceContext, RESOURCE_GUIDANCE } from "./resources.js";
|
|
|
6
6
|
import { groupScope } from "./normalize.js";
|
|
7
7
|
import { getGroupMd, getThreadMd } from "./api/rules.js";
|
|
8
8
|
import { getChannelMessagePage } from "./api/conversations.js";
|
|
9
|
-
import { compactHistoryGap, historyGapContext, IM_HISTORY_MESSAGE_LIMIT, planHistoryGap, validMessageSeq } from "../application/context-gap.js";
|
|
9
|
+
import { compactHistoryGap, historyGapContext, IM_HISTORY_MESSAGE_LIMIT, planHistoryGap, validMessageSeq, assistantOutputFingerprint } from "../application/context-gap.js";
|
|
10
10
|
import { OctoApiError } from "./api/errors.js";
|
|
11
|
-
import { MENTION_REMINDER } from "./mentions.js";
|
|
12
11
|
import { messageContent } from "./message-content.js";
|
|
12
|
+
import { rulesGuidance } from "../application/rules-context.js";
|
|
13
|
+
import { buildMessageTrigger } from "./message-trigger.js";
|
|
14
|
+
import { resolveMessageIdentities } from "./message-identities.js";
|
|
15
|
+
import { historyMessages } from "./history-messages.js";
|
|
16
|
+
import { historySenderUids, supportedHistoryType } from "./history-content.js";
|
|
17
|
+
import { modelHistoryContexts } from "../application/history-context.js";
|
|
13
18
|
export async function build_im_contexts(config, message, botToken, signal, options = { initialSession: false }) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
]);
|
|
19
|
+
// extra.im 归渠道所有;宿主静态/动态项即使本轮没有对应自动材料也不能透传。
|
|
20
|
+
const items = structuredClone((options.configuredItems ?? config.context?.items ?? []).filter((item) => item.namespace !== "extra.im"));
|
|
17
21
|
const source = {
|
|
18
22
|
service: config.api_url,
|
|
19
23
|
spaceId: config.spaceId,
|
|
@@ -27,6 +31,13 @@ export async function build_im_contexts(config, message, botToken, signal, optio
|
|
|
27
31
|
throw new Error("IM_CONTEXT_KEY_CONFLICT");
|
|
28
32
|
items.push({ namespace: "extra.im", name, payload: { source, ...payload } });
|
|
29
33
|
};
|
|
34
|
+
// 只描述真实入站事实;稳定通知规则仍由应用层按会话周期单独装配。
|
|
35
|
+
if (typeof message.channelId === "string" &&
|
|
36
|
+
typeof message.messageId === "string" &&
|
|
37
|
+
items.some((item) => item.namespace === "extra.im" && item.name === "message-trigger"))
|
|
38
|
+
throw new Error("IM_CONTEXT_KEY_CONFLICT");
|
|
39
|
+
const currentMessage = await buildMessageTrigger(config, message, botToken, signal, options.identityCache);
|
|
40
|
+
const trigger = currentMessage ? [currentMessage] : [];
|
|
30
41
|
// Octospec F01: .octospec/tasks/gateway-august-feature-assessment/assessment.md
|
|
31
42
|
// 引用是本轮业务材料;不参与命令/mention 准入,不解引用或补抓历史。
|
|
32
43
|
const reply = message.payload?.reply;
|
|
@@ -77,7 +88,7 @@ export async function build_im_contexts(config, message, botToken, signal, optio
|
|
|
77
88
|
text: doc.content,
|
|
78
89
|
version: doc.version,
|
|
79
90
|
...(doc.updated_at !== undefined ? { updatedAt: doc.updated_at } : {}),
|
|
80
|
-
status: doc.content ? "present" : "empty",
|
|
91
|
+
status: doc.content.trim() ? "present" : "empty",
|
|
81
92
|
automatic: true
|
|
82
93
|
});
|
|
83
94
|
}
|
|
@@ -90,7 +101,7 @@ export async function build_im_contexts(config, message, botToken, signal, optio
|
|
|
90
101
|
}
|
|
91
102
|
};
|
|
92
103
|
await rule("group-rules", () => getGroupMd({ apiUrl: config.api_url, botToken, groupNo: scope.groupNo, signal }));
|
|
93
|
-
if (scope.shortId)
|
|
104
|
+
if (message.channelType === 5 && scope.shortId)
|
|
94
105
|
await rule("topic-rules", () => getThreadMd({
|
|
95
106
|
apiUrl: config.api_url,
|
|
96
107
|
botToken,
|
|
@@ -100,38 +111,7 @@ export async function build_im_contexts(config, message, botToken, signal, optio
|
|
|
100
111
|
}));
|
|
101
112
|
for (const item of items)
|
|
102
113
|
if (item.namespace === "extra.im" && ["group-rules", "topic-rules"].includes(item.name))
|
|
103
|
-
item.guidance =
|
|
104
|
-
}
|
|
105
|
-
if ((options.mentionGuidance ?? options.initialSession) &&
|
|
106
|
-
!items.some((item) => item.namespace === "extra.im" && item.name === "mention-instructions")) {
|
|
107
|
-
const scope = [2, 5].includes(message.channelType) ? groupScope(message.channelId) : undefined;
|
|
108
|
-
const instructions = {
|
|
109
|
-
namespace: "extra.im",
|
|
110
|
-
name: "mention-instructions",
|
|
111
|
-
guidance: MENTION_REMINDER,
|
|
112
|
-
payload: {
|
|
113
|
-
source,
|
|
114
|
-
actorId: message.fromUid,
|
|
115
|
-
outputMarker: "@[uid:displayName]",
|
|
116
|
-
automatic: true,
|
|
117
|
-
...(scope
|
|
118
|
-
? {
|
|
119
|
-
memberLookup: {
|
|
120
|
-
groupNo: scope.groupNo,
|
|
121
|
-
argv: ["octo-cli", "group", "members", scope.groupNo],
|
|
122
|
-
fields: ["uid", "name", "robot"]
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
: {})
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
try {
|
|
129
|
-
assertContextEnvelope({ schema: CONTEXT_SCHEMA, items: [...items, instructions] });
|
|
130
|
-
items.push(instructions);
|
|
131
|
-
}
|
|
132
|
-
catch {
|
|
133
|
-
/* 可选使用指引超预算时不影响当前输入。 */
|
|
134
|
-
}
|
|
114
|
+
item.guidance = rulesGuidance(item);
|
|
135
115
|
}
|
|
136
116
|
const historyPlan = options.initialSession
|
|
137
117
|
? planHistoryGap(message.messageSeq, undefined, "cold-window")
|
|
@@ -177,27 +157,36 @@ export async function build_im_contexts(config, message, botToken, signal, optio
|
|
|
177
157
|
return true;
|
|
178
158
|
})
|
|
179
159
|
.slice(0, IM_HISTORY_MESSAGE_LIMIT);
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
.
|
|
185
|
-
|
|
160
|
+
const identities = await resolveMessageIdentities(config, [
|
|
161
|
+
...entries
|
|
162
|
+
.filter((entry) => supportedHistoryType(entry.type))
|
|
163
|
+
.map((entry) => entry.from_uid),
|
|
164
|
+
...historySenderUids(entries.map((entry) => entry.payload))
|
|
165
|
+
], botToken, signal, options.identityCache);
|
|
166
|
+
const excludedSeqs = options.initialSession || historyPlan.mode !== "delta"
|
|
167
|
+
? []
|
|
168
|
+
: entries
|
|
169
|
+
.filter((entry) => entry.from_uid === config.bot_id &&
|
|
170
|
+
historyPlan.excludedOutputs?.some((output) => output.seq === entry.message_seq &&
|
|
171
|
+
output.fingerprint === assistantOutputFingerprint({ ...entry.payload })))
|
|
172
|
+
.map((entry) => entry.message_seq);
|
|
173
|
+
const { messages, truncated, recoveryMessages } = historyMessages(entries, identities, excludedSeqs);
|
|
186
174
|
if (gap)
|
|
187
175
|
gap = {
|
|
188
176
|
...historyPlan,
|
|
189
|
-
retrieval:
|
|
177
|
+
retrieval: messages.length || recoveryMessages?.length ? "omitted" : "empty",
|
|
190
178
|
earlierOmitted: (historyPlan.earlierOmitted === true && historyPlan.mode === "delta") ||
|
|
191
179
|
page.more !== false ||
|
|
192
180
|
entries.length !== page.messages.length ||
|
|
193
|
-
entries.some((entry) => entry.type
|
|
181
|
+
entries.some((entry) => !supportedHistoryType(entry.type)) ||
|
|
194
182
|
truncated
|
|
195
183
|
};
|
|
196
|
-
if (
|
|
184
|
+
if ((messages.length || recoveryMessages?.length) &&
|
|
185
|
+
!items.some((item) => item.namespace === "extra.im" && item.name === "history")) {
|
|
197
186
|
const history = {
|
|
198
187
|
namespace: "extra.im",
|
|
199
188
|
name: "history",
|
|
200
|
-
guidance: "
|
|
189
|
+
guidance: "This data contains bounded earlier messages from the current channel.",
|
|
201
190
|
payload: {
|
|
202
191
|
source,
|
|
203
192
|
upperMessageSeq: message.messageSeq,
|
|
@@ -205,14 +194,21 @@ export async function build_im_contexts(config, message, botToken, signal, optio
|
|
|
205
194
|
beforeSeq: historyPlan.beforeSeq,
|
|
206
195
|
...(historyPlan.afterSeq !== undefined ? { afterSeq: historyPlan.afterSeq } : {})
|
|
207
196
|
},
|
|
208
|
-
|
|
197
|
+
messages,
|
|
209
198
|
truncated,
|
|
210
199
|
automatic: true
|
|
211
200
|
}
|
|
212
201
|
};
|
|
213
202
|
try {
|
|
214
|
-
assertContextEnvelope({ schema: CONTEXT_SCHEMA, items: [...items, history] });
|
|
203
|
+
assertContextEnvelope({ schema: CONTEXT_SCHEMA, items: [...items, history, ...trigger] });
|
|
215
204
|
items.push(history);
|
|
205
|
+
if (gap && recoveryMessages?.length)
|
|
206
|
+
gap.recoveryHistory = modelHistoryContexts([
|
|
207
|
+
{
|
|
208
|
+
...history,
|
|
209
|
+
payload: { ...history.payload, messages: recoveryMessages }
|
|
210
|
+
}
|
|
211
|
+
])[0];
|
|
216
212
|
if (gap)
|
|
217
213
|
gap.retrieval = gap.earlierOmitted ? "partial" : "provided";
|
|
218
214
|
}
|
|
@@ -235,13 +231,16 @@ export async function build_im_contexts(config, message, botToken, signal, optio
|
|
|
235
231
|
throw new Error("IM_CONTEXT_KEY_CONFLICT");
|
|
236
232
|
if (candidate) {
|
|
237
233
|
try {
|
|
238
|
-
assertContextEnvelope({ schema: CONTEXT_SCHEMA, items: [...items, candidate] });
|
|
234
|
+
assertContextEnvelope({ schema: CONTEXT_SCHEMA, items: [...items, candidate, ...trigger] });
|
|
239
235
|
}
|
|
240
236
|
catch {
|
|
241
237
|
candidate = compactHistoryGap(candidate);
|
|
242
238
|
try {
|
|
243
239
|
if (candidate)
|
|
244
|
-
assertContextEnvelope({
|
|
240
|
+
assertContextEnvelope({
|
|
241
|
+
schema: CONTEXT_SCHEMA,
|
|
242
|
+
items: [...items, candidate, ...trigger]
|
|
243
|
+
});
|
|
245
244
|
}
|
|
246
245
|
catch {
|
|
247
246
|
candidate = undefined;
|
|
@@ -251,36 +250,8 @@ export async function build_im_contexts(config, message, botToken, signal, optio
|
|
|
251
250
|
items.push(candidate);
|
|
252
251
|
}
|
|
253
252
|
}
|
|
253
|
+
items.push(...trigger);
|
|
254
254
|
const envelope = { schema: CONTEXT_SCHEMA, items };
|
|
255
255
|
assertContextEnvelope(envelope);
|
|
256
256
|
return items;
|
|
257
257
|
}
|
|
258
|
-
export function historyText(entries) {
|
|
259
|
-
const marker = "<历史已截断>";
|
|
260
|
-
const selected = [];
|
|
261
|
-
let remaining = 1500;
|
|
262
|
-
for (const entry of entries) {
|
|
263
|
-
if (entry.type !== 1 || typeof entry.content !== "string" || !entry.content.trim())
|
|
264
|
-
continue;
|
|
265
|
-
const line = Array.from(`${entry.from_uid}:${entry.content}`);
|
|
266
|
-
const separator = selected.length ? 1 : 0;
|
|
267
|
-
if (line.length + separator <= remaining) {
|
|
268
|
-
selected.unshift(line.join(""));
|
|
269
|
-
remaining -= line.length + separator;
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
const available = remaining - separator - Array.from(marker).length;
|
|
273
|
-
if (available > 0)
|
|
274
|
-
selected.unshift(marker + line.slice(-available).join(""));
|
|
275
|
-
else if (selected.length) {
|
|
276
|
-
const text = selected.join("\n");
|
|
277
|
-
return (marker +
|
|
278
|
-
Array.from(text)
|
|
279
|
-
.slice(-(1500 - Array.from(marker).length))
|
|
280
|
-
.join(""));
|
|
281
|
-
}
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return selected.join("\n");
|
|
286
|
-
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MessageIdentity } from "./message-identities.js";
|
|
2
|
+
type Data = Record<string, unknown>;
|
|
3
|
+
export declare const historyObject: (value: unknown) => Data;
|
|
4
|
+
export declare const supportedHistoryType: (type: unknown) => boolean;
|
|
5
|
+
/** 只收集有限层级的真实来源 UID;转发自报姓名不参与可信身份映射。 */
|
|
6
|
+
export declare function historySenderUids(payloads: unknown[]): string[];
|
|
7
|
+
/** 历史只携带已返回的内容结构和资源地址,不下载、解引用或把嵌套材料当新任务。 */
|
|
8
|
+
export declare function historyContent(raw: unknown, identities: ReadonlyMap<string, MessageIdentity>): {
|
|
9
|
+
content: Data;
|
|
10
|
+
truncated: boolean;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { messageSentAt } from "./message-time.js";
|
|
2
|
+
export const historyObject = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
3
|
+
const field = (value, limit = 256) => typeof value === "string" && value.length <= limit ? value : null;
|
|
4
|
+
export const supportedHistoryType = (type) => typeof type === "number" && [1, 2, 8, 11, 14, 18].includes(type);
|
|
5
|
+
/** 只收集有限层级的真实来源 UID;转发自报姓名不参与可信身份映射。 */
|
|
6
|
+
export function historySenderUids(payloads) {
|
|
7
|
+
const result = new Set();
|
|
8
|
+
let nodes = 0;
|
|
9
|
+
const visit = (raw, depth) => {
|
|
10
|
+
if (depth >= 4 || ++nodes > 128)
|
|
11
|
+
return;
|
|
12
|
+
const value = historyObject(raw);
|
|
13
|
+
const quote = historyObject(value.reply);
|
|
14
|
+
if (typeof quote.from_uid === "string")
|
|
15
|
+
result.add(quote.from_uid);
|
|
16
|
+
if (quote.payload)
|
|
17
|
+
visit(quote.payload, depth + 1);
|
|
18
|
+
if (value.type === 11 && Array.isArray(value.msgs))
|
|
19
|
+
for (const rawMessage of value.msgs.slice(0, 128)) {
|
|
20
|
+
if (nodes >= 128)
|
|
21
|
+
break;
|
|
22
|
+
const message = historyObject(rawMessage);
|
|
23
|
+
if (typeof message.from_uid === "string")
|
|
24
|
+
result.add(message.from_uid);
|
|
25
|
+
visit(message.payload, depth + 1);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
for (const value of payloads)
|
|
29
|
+
visit(value, 0);
|
|
30
|
+
return [...result];
|
|
31
|
+
}
|
|
32
|
+
/** 历史只携带已返回的内容结构和资源地址,不下载、解引用或把嵌套材料当新任务。 */
|
|
33
|
+
export function historyContent(raw, identities) {
|
|
34
|
+
let nodes = 0, remaining = 12000, truncated = false;
|
|
35
|
+
const text = (value) => {
|
|
36
|
+
if (typeof value !== "string")
|
|
37
|
+
return "";
|
|
38
|
+
const points = Array.from(value);
|
|
39
|
+
if (points.length > remaining)
|
|
40
|
+
truncated = true;
|
|
41
|
+
const result = points.slice(0, remaining).join("");
|
|
42
|
+
remaining -= Math.min(points.length, remaining);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
const speaker = (value) => {
|
|
46
|
+
const uid = field(value.from_uid, 64);
|
|
47
|
+
return {
|
|
48
|
+
uid,
|
|
49
|
+
username: uid ? (identities.get(uid)?.name ?? null) : null,
|
|
50
|
+
sentAt: messageSentAt(value.timestamp, "seconds")
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const visit = (value, depth) => {
|
|
54
|
+
if (depth >= 4 || ++nodes > 128) {
|
|
55
|
+
truncated = true;
|
|
56
|
+
return { type: "omitted", reason: "nesting-limit" };
|
|
57
|
+
}
|
|
58
|
+
const payload = historyObject(value);
|
|
59
|
+
let body;
|
|
60
|
+
if (payload.type === 1)
|
|
61
|
+
body = { type: "text", text: text(payload.content) };
|
|
62
|
+
else if (payload.type === 2)
|
|
63
|
+
body = { type: "image", url: field(payload.url, 8192), read: false };
|
|
64
|
+
else if (payload.type === 8)
|
|
65
|
+
body = {
|
|
66
|
+
type: "file",
|
|
67
|
+
name: field(payload.name),
|
|
68
|
+
url: field(payload.url, 8192),
|
|
69
|
+
read: false
|
|
70
|
+
};
|
|
71
|
+
else if (payload.type === 18)
|
|
72
|
+
body = {
|
|
73
|
+
type: "document",
|
|
74
|
+
id: field(payload.doc_id),
|
|
75
|
+
name: field(payload.title),
|
|
76
|
+
url: field(payload.url, 8192),
|
|
77
|
+
read: false
|
|
78
|
+
};
|
|
79
|
+
else if (payload.type === 11) {
|
|
80
|
+
const messages = [];
|
|
81
|
+
if (Array.isArray(payload.msgs))
|
|
82
|
+
for (const entry of payload.msgs.slice(0, 128)) {
|
|
83
|
+
if (nodes >= 128) {
|
|
84
|
+
truncated = true;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
const message = historyObject(entry);
|
|
88
|
+
messages.push({ ...speaker(message), content: visit(message.payload, depth + 1) });
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(payload.msgs) && payload.msgs.length > 128)
|
|
91
|
+
truncated = true;
|
|
92
|
+
body = { type: "forward", messages };
|
|
93
|
+
}
|
|
94
|
+
else if (payload.type === 14) {
|
|
95
|
+
if (Array.isArray(payload.content)) {
|
|
96
|
+
const blocks = [];
|
|
97
|
+
for (const block of payload.content.slice(0, 128)) {
|
|
98
|
+
if (++nodes > 128) {
|
|
99
|
+
truncated = true;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
const data = historyObject(block);
|
|
103
|
+
if (data.type === "text")
|
|
104
|
+
blocks.push({ type: "text", text: text(data.text) });
|
|
105
|
+
else if (data.type === "image")
|
|
106
|
+
blocks.push({ type: "image", url: field(data.url, 8192), read: false });
|
|
107
|
+
else
|
|
108
|
+
blocks.push({ type: "unsupported" });
|
|
109
|
+
}
|
|
110
|
+
if (payload.content.length > 128)
|
|
111
|
+
truncated = true;
|
|
112
|
+
body = { type: "rich-text", blocks };
|
|
113
|
+
}
|
|
114
|
+
else
|
|
115
|
+
body = {
|
|
116
|
+
type: "text",
|
|
117
|
+
text: text(typeof payload.plain === "string" ? payload.plain : payload.content)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
body = { type: "unsupported" };
|
|
122
|
+
const quote = historyObject(payload.reply);
|
|
123
|
+
if (Object.keys(quote).length)
|
|
124
|
+
body = {
|
|
125
|
+
type: "reply",
|
|
126
|
+
quote: { ...speaker(quote), content: visit(quote.payload, depth + 1) },
|
|
127
|
+
content: body
|
|
128
|
+
};
|
|
129
|
+
return body;
|
|
130
|
+
};
|
|
131
|
+
const content = visit(raw, 0);
|
|
132
|
+
return { content, truncated };
|
|
133
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MessageIdentity } from "./message-identities.js";
|
|
2
|
+
export interface HistoryMessage {
|
|
3
|
+
uid: string;
|
|
4
|
+
username: string | null;
|
|
5
|
+
sentAt: string | null;
|
|
6
|
+
content: Record<string, unknown>;
|
|
7
|
+
truncated?: true;
|
|
8
|
+
}
|
|
9
|
+
/** 输入按新到旧;输出按旧到新,8000 码点预算包含 JSON,截断只影响正文。 */
|
|
10
|
+
export declare function historyMessages(entries: Array<{
|
|
11
|
+
from_uid: string;
|
|
12
|
+
content: string;
|
|
13
|
+
timestamp?: number | null;
|
|
14
|
+
type?: number;
|
|
15
|
+
payload?: unknown;
|
|
16
|
+
message_seq?: number;
|
|
17
|
+
}>, identities?: ReadonlyMap<string, MessageIdentity>, excludedSeqs?: readonly number[]): {
|
|
18
|
+
messages: HistoryMessage[];
|
|
19
|
+
truncated: boolean;
|
|
20
|
+
recoveryMessages?: HistoryMessage[];
|
|
21
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { historyContent, historyObject, supportedHistoryType } from "./history-content.js";
|
|
2
|
+
import { messageSentAt } from "./message-time.js";
|
|
3
|
+
import { IM_HISTORY_MESSAGE_LIMIT } from "../application/context-gap.js";
|
|
4
|
+
/** 输入按新到旧;输出按旧到新,8000 码点预算包含 JSON,截断只影响正文。 */
|
|
5
|
+
export function historyMessages(entries, identities = new Map(), excludedSeqs = []) {
|
|
6
|
+
const messages = [];
|
|
7
|
+
const excluded = new Set();
|
|
8
|
+
const size = (value) => Array.from(JSON.stringify(value)).length;
|
|
9
|
+
let truncated = false;
|
|
10
|
+
for (const entry of entries.slice(0, IM_HISTORY_MESSAGE_LIMIT)) {
|
|
11
|
+
// 先对完整窗口执行原预算;恢复与主历史只是同一材料的互不重叠分区。
|
|
12
|
+
const prepend = (record) => {
|
|
13
|
+
messages.unshift(record);
|
|
14
|
+
if (entry.message_seq !== undefined && excludedSeqs.includes(entry.message_seq))
|
|
15
|
+
excluded.add(record);
|
|
16
|
+
};
|
|
17
|
+
if (!supportedHistoryType(entry.type))
|
|
18
|
+
continue;
|
|
19
|
+
const payload = historyObject(entry.payload ?? { type: entry.type, content: entry.content });
|
|
20
|
+
const plain = entry.type === 1 && !Object.keys(historyObject(payload.reply)).length;
|
|
21
|
+
if (plain && (typeof entry.content !== "string" || !entry.content.trim()))
|
|
22
|
+
continue;
|
|
23
|
+
const body = plain ? undefined : historyContent(payload, identities);
|
|
24
|
+
const record = {
|
|
25
|
+
uid: entry.from_uid,
|
|
26
|
+
username: identities.get(entry.from_uid)?.name ?? null,
|
|
27
|
+
sentAt: messageSentAt(entry.timestamp, "milliseconds"),
|
|
28
|
+
content: plain ? { type: "text", text: entry.content } : body.content,
|
|
29
|
+
...(body?.truncated ? { truncated: true } : {})
|
|
30
|
+
};
|
|
31
|
+
if (size([record, ...messages]) <= 8000) {
|
|
32
|
+
prepend(record);
|
|
33
|
+
truncated ||= body?.truncated === true;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// 尾部保留最新正文;JSON 转义也占预算,二分选择可容纳的 Unicode 尾段。
|
|
37
|
+
if (!plain) {
|
|
38
|
+
const omitted = {
|
|
39
|
+
uid: record.uid,
|
|
40
|
+
username: record.username,
|
|
41
|
+
sentAt: record.sentAt,
|
|
42
|
+
content: { type: "omitted", reason: "history-budget" },
|
|
43
|
+
truncated: true
|
|
44
|
+
};
|
|
45
|
+
if (size([omitted, ...messages]) <= 8000)
|
|
46
|
+
prepend(omitted);
|
|
47
|
+
truncated = true;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
const tail = Array.from(entry.content).slice(-8000);
|
|
51
|
+
let low = 0, high = tail.length;
|
|
52
|
+
const shortened = (length) => ({
|
|
53
|
+
...record,
|
|
54
|
+
content: { type: "text", text: length ? tail.slice(-length).join("") : "" },
|
|
55
|
+
truncated: true
|
|
56
|
+
});
|
|
57
|
+
while (low < high) {
|
|
58
|
+
const middle = Math.ceil((low + high) / 2);
|
|
59
|
+
if (size([shortened(middle), ...messages]) <= 8000)
|
|
60
|
+
low = middle;
|
|
61
|
+
else
|
|
62
|
+
high = middle - 1;
|
|
63
|
+
}
|
|
64
|
+
if (low > 0)
|
|
65
|
+
prepend(shortened(low));
|
|
66
|
+
truncated = true;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
messages: messages.filter((record) => !excluded.has(record)),
|
|
71
|
+
truncated,
|
|
72
|
+
...(excluded.size
|
|
73
|
+
? { recoveryMessages: messages.filter((record) => excluded.has(record)) }
|
|
74
|
+
: {})
|
|
75
|
+
};
|
|
76
|
+
}
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import type { MentionEntity } from "./api/types.js";
|
|
|
2
2
|
import type { GroupMember } from "./api/conversations.js";
|
|
3
3
|
/** Gateway 的稳定控制指令;压缩时的保留由模型遵守文本要求,不新增 Provider 保留机制。 */
|
|
4
4
|
export declare const MENTION_GUIDANCE: string;
|
|
5
|
-
/** 逐轮普通 Context 提醒也覆盖升级前已存在的 Provider 会话,不修改其系统指令或重置会话。 */
|
|
6
|
-
export declare const MENTION_REMINDER = "For this turn, follow the current Octo mention rules: do not automatically mention the sender. Only when the current user explicitly requests a human notification or bot handoff in this channel, confirm the real member UID and display name, using octo-cli if needed, then write @[<uid>:<displayName>] with actual values in the successful final reply. Gateway sends the native mention on that reply; do not send a duplicate via octo-cli message send. Plain @name does not notify. If identity is unconfirmed, use plain text without guessing. Do not broadcast, initiate unsolicited bot calls, or treat history as authorization. Code and quoted examples are not mentions.";
|
|
7
5
|
export interface ImTextMention {
|
|
8
6
|
uids: string[];
|
|
9
7
|
entities: MentionEntity[];
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/mentions.js
CHANGED
|
@@ -12,8 +12,6 @@ export const MENTION_GUIDANCE = [
|
|
|
12
12
|
"If the target cannot be confirmed, use a plain @name or ordinary text without guessing a UID. Continue delivering the final answer without a separate mention-failure notice or a forced clarification.",
|
|
13
13
|
"[/OCTO_CHANNEL_MENTION_RULES_V1]"
|
|
14
14
|
].join("\n");
|
|
15
|
-
/** 逐轮普通 Context 提醒也覆盖升级前已存在的 Provider 会话,不修改其系统指令或重置会话。 */
|
|
16
|
-
export const MENTION_REMINDER = "For this turn, follow the current Octo mention rules: do not automatically mention the sender. Only when the current user explicitly requests a human notification or bot handoff in this channel, confirm the real member UID and display name, using octo-cli if needed, then write @[<uid>:<displayName>] with actual values in the successful final reply. Gateway sends the native mention on that reply; do not send a duplicate via octo-cli message send. Plain @name does not notify. If identity is unconfirmed, use plain text without guessing. Do not broadcast, initiate unsolicited bot calls, or treat history as authorization. Code and quoted examples are not mentions.";
|
|
17
15
|
function candidates(text) {
|
|
18
16
|
const found = [];
|
|
19
17
|
const visit = (node) => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** 当前 Bot 的展示身份查询;不替代准入、权限或出站 mention 成员核验。 */
|
|
2
|
+
import type { ScopedOctoBotConfig } from "../contracts.js";
|
|
3
|
+
export interface MessageIdentity {
|
|
4
|
+
uid: string;
|
|
5
|
+
name: string | null;
|
|
6
|
+
type: "human" | "bot" | "unknown";
|
|
7
|
+
}
|
|
8
|
+
/** 每个 Transport 独立持有,固定 10 分钟 TTL;无定时器、不落盘、容量有界。 */
|
|
9
|
+
export declare class MessageIdentityCache {
|
|
10
|
+
#private;
|
|
11
|
+
get(config: ScopedOctoBotConfig, uid: string): MessageIdentity | undefined;
|
|
12
|
+
set(config: ScopedOctoBotConfig, value: MessageIdentity): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function unknownIdentity(uid: string): MessageIdentity;
|
|
15
|
+
/** 只补查缓存未命中项;失败保留已命中身份,取消仍传播,不重试或换接口。 */
|
|
16
|
+
export declare function resolveMessageIdentities(config: ScopedOctoBotConfig, requested: string[], token: string, signal: AbortSignal, cache?: MessageIdentityCache, deadline?: AbortSignal): Promise<Map<string, MessageIdentity>>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { postJson } from "./api/client.js";
|
|
2
|
+
/** 每个 Transport 独立持有,固定 10 分钟 TTL;无定时器、不落盘、容量有界。 */
|
|
3
|
+
export class MessageIdentityCache {
|
|
4
|
+
#entries = new Map();
|
|
5
|
+
#key(config, uid) {
|
|
6
|
+
return JSON.stringify([config.api_url, config.bot_id, config.spaceId, uid]);
|
|
7
|
+
}
|
|
8
|
+
get(config, uid) {
|
|
9
|
+
const key = this.#key(config, uid);
|
|
10
|
+
const entry = this.#entries.get(key);
|
|
11
|
+
if (!entry)
|
|
12
|
+
return undefined;
|
|
13
|
+
if (entry.expiresAt <= Date.now()) {
|
|
14
|
+
this.#entries.delete(key);
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return { ...entry.value };
|
|
18
|
+
}
|
|
19
|
+
set(config, value) {
|
|
20
|
+
if (value.name === null && value.type === "unknown")
|
|
21
|
+
return;
|
|
22
|
+
const key = this.#key(config, value.uid);
|
|
23
|
+
this.#entries.delete(key);
|
|
24
|
+
this.#entries.set(key, { value: { ...value }, expiresAt: Date.now() + 600_000 });
|
|
25
|
+
while (this.#entries.size > 2000)
|
|
26
|
+
this.#entries.delete(this.#entries.keys().next().value);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function unknownIdentity(uid) {
|
|
30
|
+
return { uid, name: null, type: "unknown" };
|
|
31
|
+
}
|
|
32
|
+
/** 只补查缓存未命中项;失败保留已命中身份,取消仍传播,不重试或换接口。 */
|
|
33
|
+
export async function resolveMessageIdentities(config, requested, token, signal, cache, deadline = AbortSignal.any([signal, AbortSignal.timeout(5_000)])) {
|
|
34
|
+
signal.throwIfAborted();
|
|
35
|
+
const result = new Map();
|
|
36
|
+
const missing = [];
|
|
37
|
+
for (const uid of new Set(requested)) {
|
|
38
|
+
const hit = cache?.get(config, uid);
|
|
39
|
+
if (hit)
|
|
40
|
+
result.set(uid, hit);
|
|
41
|
+
else if (uid && Buffer.byteLength(uid) <= 64 && missing.length < 200)
|
|
42
|
+
missing.push(uid);
|
|
43
|
+
}
|
|
44
|
+
if (!missing.length)
|
|
45
|
+
return result;
|
|
46
|
+
try {
|
|
47
|
+
const response = await postJson(config.api_url, token, "/v1/bot/users/batch", { uids: missing }, deadline, { retryOn429: false, logRateLimit: false, maxResponseBytes: 1_048_576 });
|
|
48
|
+
const wanted = new Set(missing);
|
|
49
|
+
for (const value of (Array.isArray(response?.users) ? response.users : [])) {
|
|
50
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
51
|
+
continue;
|
|
52
|
+
const row = value;
|
|
53
|
+
if (typeof row.uid !== "string" || !wanted.has(row.uid))
|
|
54
|
+
continue;
|
|
55
|
+
const identity = {
|
|
56
|
+
uid: row.uid,
|
|
57
|
+
name: typeof row.name === "string" && row.name.trim() && Array.from(row.name).length <= 256
|
|
58
|
+
? row.name
|
|
59
|
+
: null,
|
|
60
|
+
type: row.robot === true || row.robot === 1
|
|
61
|
+
? "bot"
|
|
62
|
+
: row.robot === false || row.robot === 0
|
|
63
|
+
? "human"
|
|
64
|
+
: "unknown"
|
|
65
|
+
};
|
|
66
|
+
result.set(identity.uid, identity);
|
|
67
|
+
cache?.set(config, identity);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
signal.throwIfAborted();
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** API/WS 时间为秒,已解码历史为毫秒;单位由调用方明确,缺失或无效时间不补为当前时间。 */
|
|
2
|
+
export declare function messageDate(timestamp: unknown, unit: "seconds" | "milliseconds"): Date | undefined;
|
|
3
|
+
/** 按该消息时刻的系统时区输出 ISO 8601,保留显式偏移(含夏令时),不转换为 UTC Z。 */
|
|
4
|
+
export declare function messageSentAt(timestamp: unknown, unit: "seconds" | "milliseconds"): string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** API/WS 时间为秒,已解码历史为毫秒;单位由调用方明确,缺失或无效时间不补为当前时间。 */
|
|
2
|
+
export function messageDate(timestamp, unit) {
|
|
3
|
+
if (typeof timestamp !== "number" || !Number.isSafeInteger(timestamp) || timestamp <= 0)
|
|
4
|
+
return undefined;
|
|
5
|
+
const milliseconds = unit === "seconds" ? timestamp * 1000 : timestamp;
|
|
6
|
+
if (milliseconds > 0xffffffff * 1000)
|
|
7
|
+
return undefined;
|
|
8
|
+
return new Date(milliseconds);
|
|
9
|
+
}
|
|
10
|
+
/** 按该消息时刻的系统时区输出 ISO 8601,保留显式偏移(含夏令时),不转换为 UTC Z。 */
|
|
11
|
+
export function messageSentAt(timestamp, unit) {
|
|
12
|
+
const date = messageDate(timestamp, unit);
|
|
13
|
+
if (!date)
|
|
14
|
+
return null;
|
|
15
|
+
const pad = (value, width = 2) => String(value).padStart(width, "0");
|
|
16
|
+
const offset = -date.getTimezoneOffset();
|
|
17
|
+
const zone = `${offset >= 0 ? "+" : "-"}${pad(Math.floor(Math.abs(offset) / 60))}:${pad(Math.abs(offset) % 60)}`;
|
|
18
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}${zone}`;
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** 本轮触发事实:只补查已准入消息的会话和身份,缺失信息不从正文或 UID 猜测。 */
|
|
2
|
+
import type { ContextItem } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
|
+
import type { ScopedOctoBotConfig } from "../contracts.js";
|
|
4
|
+
import type { ImMessage } from "./wukong.js";
|
|
5
|
+
import { type MessageIdentityCache } from "./message-identities.js";
|
|
6
|
+
/** 返回模型可读 JSON;外部取消继续传播,补充信息失败只留下真实 ID 和未知值。 */
|
|
7
|
+
export declare function buildMessageTrigger(config: ScopedOctoBotConfig, message: ImMessage, token: string, signal: AbortSignal, cache?: MessageIdentityCache): Promise<ContextItem | undefined>;
|