@ai-agent-forge/plugin-overflow-policy 0.88.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @agent-forge/plugin-overflow-policy
2
+
3
+ Agent Forge 出厂默认溢出策略插件(context overflow 与 recoverable length 分类 decide),bundled 分发,宿主通过 manifest 加载并经供给基座注入共享模块。
@@ -0,0 +1,19 @@
1
+ {
2
+ "packageFormatVersion": 1,
3
+ "id": "agent-forge.plugin.overflow-policy",
4
+ "pluginVersion": "0.88.1",
5
+ "apiVersion": "1",
6
+ "minHostVersion": "0.88.0",
7
+ "platform": {
8
+ "os": [
9
+ "windows",
10
+ "macos",
11
+ "linux"
12
+ ],
13
+ "runtime": [
14
+ {
15
+ "name": "node"
16
+ }
17
+ ]
18
+ }
19
+ }
@@ -0,0 +1,16 @@
1
+ import type { CapabilityAPI } from "@agent-forge/plugin-sdk";
2
+ /** Policy name under the `overflow-policy` capability; matches the host's embedded default name. */
3
+ export declare const DEFAULT_OVERFLOW_POLICY_NAME = "default";
4
+ /**
5
+ * Default-export factory consumed by the host's manifest plugin loader.
6
+ *
7
+ * Registers the current provider classification (overflow and recoverable-length
8
+ * logic migrated verbatim from the host's embedded `bootstrap-overflow-policy.ts`,
9
+ * D-082 batch 3) under the fixed default name: rerouting via overflowPolicyName
10
+ * config selects a different policy, while a same-name registration competes by
11
+ * load order — it is not a replacement mechanism.
12
+ */
13
+ export default function createOverflowPolicyPluginEntry(api: CapabilityAPI): Promise<{
14
+ dispose: () => void;
15
+ }>;
16
+ //# sourceMappingURL=entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAyB,MAAM,yBAAyB,CAAC;AAEpF,oGAAoG;AACpG,eAAO,MAAM,4BAA4B,YAAY,CAAC;AAEtD;;;;;;;;GAQG;AACH,wBAA8B,+BAA+B,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC,CAoBlH","sourcesContent":["import { type AssistantMessage, isContextOverflow, isRecoverableLength } from \"@agent-forge/ai/compat\";\nimport { t } from \"@agent-forge/host/i18n\";\nimport type { CapabilityAPI, OverflowPolicyRequest } from \"@agent-forge/plugin-sdk\";\n\n/** Policy name under the `overflow-policy` capability; matches the host's embedded default name. */\nexport const DEFAULT_OVERFLOW_POLICY_NAME = \"default\";\n\n/**\n * Default-export factory consumed by the host's manifest plugin loader.\n *\n * Registers the current provider classification (overflow and recoverable-length\n * logic migrated verbatim from the host's embedded `bootstrap-overflow-policy.ts`,\n * D-082 batch 3) under the fixed default name: rerouting via overflowPolicyName\n * config selects a different policy, while a same-name registration competes by\n * load order — it is not a replacement mechanism.\n */\nexport default async function createOverflowPolicyPluginEntry(api: CapabilityAPI): Promise<{ dispose: () => void }> {\n\tconst registration = api.registerOverflowPolicy(DEFAULT_OVERFLOW_POLICY_NAME, {\n\t\tdecide: (request: OverflowPolicyRequest) => {\n\t\t\tif (!request.message || typeof request.message !== \"object\") {\n\t\t\t\tthrow new Error(t(\"Overflow policy requires an assistant message object\"));\n\t\t\t}\n\t\t\tconst message = request.message as AssistantMessage;\n\t\t\treturn {\n\t\t\t\tcontextOverflow: isContextOverflow(message, request.contextWindow),\n\t\t\t\trecoverableLength: isRecoverableLength(message, request.desiredMaxOutput),\n\t\t\t};\n\t\t},\n\t});\n\treturn {\n\t\tdispose: () => {\n\t\t\t// Registration disposal in the capability runtime is synchronous;\n\t\t\t// void consumes the declared Promise possibility of the contract.\n\t\t\tvoid registration.dispose();\n\t\t},\n\t};\n}\n"]}
package/dist/entry.js ADDED
@@ -0,0 +1,35 @@
1
+ import { isContextOverflow, isRecoverableLength } from "@agent-forge/ai/compat";
2
+ import { t } from "@agent-forge/host/i18n";
3
+ /** Policy name under the `overflow-policy` capability; matches the host's embedded default name. */
4
+ export const DEFAULT_OVERFLOW_POLICY_NAME = "default";
5
+ /**
6
+ * Default-export factory consumed by the host's manifest plugin loader.
7
+ *
8
+ * Registers the current provider classification (overflow and recoverable-length
9
+ * logic migrated verbatim from the host's embedded `bootstrap-overflow-policy.ts`,
10
+ * D-082 batch 3) under the fixed default name: rerouting via overflowPolicyName
11
+ * config selects a different policy, while a same-name registration competes by
12
+ * load order — it is not a replacement mechanism.
13
+ */
14
+ export default async function createOverflowPolicyPluginEntry(api) {
15
+ const registration = api.registerOverflowPolicy(DEFAULT_OVERFLOW_POLICY_NAME, {
16
+ decide: (request) => {
17
+ if (!request.message || typeof request.message !== "object") {
18
+ throw new Error(t("Overflow policy requires an assistant message object"));
19
+ }
20
+ const message = request.message;
21
+ return {
22
+ contextOverflow: isContextOverflow(message, request.contextWindow),
23
+ recoverableLength: isRecoverableLength(message, request.desiredMaxOutput),
24
+ };
25
+ },
26
+ });
27
+ return {
28
+ dispose: () => {
29
+ // Registration disposal in the capability runtime is synchronous;
30
+ // void consumes the declared Promise possibility of the contract.
31
+ void registration.dispose();
32
+ },
33
+ };
34
+ }
35
+ //# sourceMappingURL=entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C,oGAAoG;AACpG,MAAM,CAAC,MAAM,4BAA4B,GAAG,SAAS,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,+BAA+B,CAAC,GAAkB,EAAoC;IACnH,MAAM,YAAY,GAAG,GAAG,CAAC,sBAAsB,CAAC,4BAA4B,EAAE;QAC7E,MAAM,EAAE,CAAC,OAA8B,EAAE,EAAE,CAAC;YAC3C,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAC7D,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,sDAAsD,CAAC,CAAC,CAAC;YAC5E,CAAC;YACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAA2B,CAAC;YACpD,OAAO;gBACN,eAAe,EAAE,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC;gBAClE,iBAAiB,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC;aACzE,CAAC;QAAA,CACF;KACD,CAAC,CAAC;IACH,OAAO;QACN,OAAO,EAAE,GAAG,EAAE,CAAC;YACd,kEAAkE;YAClE,kEAAkE;YAClE,KAAK,YAAY,CAAC,OAAO,EAAE,CAAC;QAAA,CAC5B;KACD,CAAC;AAAA,CACF","sourcesContent":["import { type AssistantMessage, isContextOverflow, isRecoverableLength } from \"@agent-forge/ai/compat\";\nimport { t } from \"@agent-forge/host/i18n\";\nimport type { CapabilityAPI, OverflowPolicyRequest } from \"@agent-forge/plugin-sdk\";\n\n/** Policy name under the `overflow-policy` capability; matches the host's embedded default name. */\nexport const DEFAULT_OVERFLOW_POLICY_NAME = \"default\";\n\n/**\n * Default-export factory consumed by the host's manifest plugin loader.\n *\n * Registers the current provider classification (overflow and recoverable-length\n * logic migrated verbatim from the host's embedded `bootstrap-overflow-policy.ts`,\n * D-082 batch 3) under the fixed default name: rerouting via overflowPolicyName\n * config selects a different policy, while a same-name registration competes by\n * load order — it is not a replacement mechanism.\n */\nexport default async function createOverflowPolicyPluginEntry(api: CapabilityAPI): Promise<{ dispose: () => void }> {\n\tconst registration = api.registerOverflowPolicy(DEFAULT_OVERFLOW_POLICY_NAME, {\n\t\tdecide: (request: OverflowPolicyRequest) => {\n\t\t\tif (!request.message || typeof request.message !== \"object\") {\n\t\t\t\tthrow new Error(t(\"Overflow policy requires an assistant message object\"));\n\t\t\t}\n\t\t\tconst message = request.message as AssistantMessage;\n\t\t\treturn {\n\t\t\t\tcontextOverflow: isContextOverflow(message, request.contextWindow),\n\t\t\t\trecoverableLength: isRecoverableLength(message, request.desiredMaxOutput),\n\t\t\t};\n\t\t},\n\t});\n\treturn {\n\t\tdispose: () => {\n\t\t\t// Registration disposal in the capability runtime is synchronous;\n\t\t\t// void consumes the declared Promise possibility of the contract.\n\t\t\tvoid registration.dispose();\n\t\t},\n\t};\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@ai-agent-forge/plugin-overflow-policy",
3
+ "version": "0.88.1",
4
+ "description": "Default overflow policy plugin for Agent Forge (context-overflow and recoverable-length classification)",
5
+ "type": "module",
6
+ "main": "./dist/entry.js",
7
+ "types": "./dist/entry.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/entry.d.ts",
11
+ "import": "./dist/entry.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "agent-forge.json",
17
+ "plugin.json",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "clean": "shx rm -rf dist",
22
+ "build": "tsgo -p tsconfig.build.json",
23
+ "test": "vitest --run",
24
+ "prepublishOnly": "npm run clean && npm run build"
25
+ },
26
+ "keywords": [
27
+ "agent-forge",
28
+ "plugin",
29
+ "overflow-policy"
30
+ ],
31
+ "author": "Agent Forge contributors",
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/agent-forge/agent-forge.git",
36
+ "directory": "plugins/overflow-policy"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/agent-forge/agent-forge/issues"
40
+ },
41
+ "homepage": "https://github.com/agent-forge/agent-forge#readme",
42
+ "engines": {
43
+ "node": ">=22.19.0"
44
+ },
45
+ "dependencies": {},
46
+ "devDependencies": {
47
+ "shx": "0.4.0",
48
+ "vitest": "4.1.11"
49
+ }
50
+ }
package/plugin.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "id": "agent-forge.plugin.overflow-policy",
3
+ "version": "0.88.1",
4
+ "apiVersion": "1-draft",
5
+ "entry": "./dist/entry.js",
6
+ "hostVersion": ">=0.88.0",
7
+ "requiredCapabilities": [
8
+ "overflow-policy"
9
+ ]
10
+ }