context-mode 1.0.135 → 1.0.136

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.
Files changed (37) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/hooks.json +65 -0
  4. package/.codex-plugin/mcp.json +9 -0
  5. package/.codex-plugin/plugin.json +31 -0
  6. package/.openclaw-plugin/openclaw.plugin.json +1 -1
  7. package/.openclaw-plugin/package.json +1 -1
  8. package/README.md +60 -12
  9. package/build/adapters/pi/mcp-bridge.d.ts +37 -1
  10. package/build/adapters/pi/mcp-bridge.js +135 -21
  11. package/build/lifecycle.d.ts +13 -13
  12. package/build/lifecycle.js +14 -14
  13. package/build/session/extract.js +39 -1
  14. package/cli.bundle.mjs +3 -3
  15. package/configs/kilo/kilo.json +9 -2
  16. package/configs/opencode/opencode.json +9 -2
  17. package/hooks/codex/platform.mjs +1 -0
  18. package/hooks/codex/posttooluse.mjs +1 -0
  19. package/hooks/codex/precompact.mjs +1 -0
  20. package/hooks/codex/pretooluse.mjs +1 -0
  21. package/hooks/codex/sessionstart.mjs +1 -0
  22. package/hooks/codex/stop.mjs +1 -0
  23. package/hooks/codex/userpromptsubmit.mjs +1 -0
  24. package/hooks/core/routing.mjs +112 -10
  25. package/hooks/ensure-deps.mjs +14 -3
  26. package/hooks/session-extract.bundle.mjs +2 -2
  27. package/openclaw.plugin.json +1 -1
  28. package/package.json +2 -1
  29. package/server.bundle.mjs +4 -4
  30. package/build/openclaw-plugin.d.ts +0 -130
  31. package/build/openclaw-plugin.js +0 -626
  32. package/build/opencode-plugin.d.ts +0 -122
  33. package/build/opencode-plugin.js +0 -372
  34. package/build/pi-extension.d.ts +0 -14
  35. package/build/pi-extension.js +0 -451
  36. package/build/util/db-lock.d.ts +0 -65
  37. package/build/util/db-lock.js +0 -166
@@ -1,130 +0,0 @@
1
- /**
2
- * OpenClaw TypeScript plugin entry point for context-mode.
3
- *
4
- * Exports an object with { id, name, configSchema, register(api) } for
5
- * declarative metadata and config validation before code execution.
6
- *
7
- * register(api) registers:
8
- * - before_tool_call hook — Routing enforcement (deny/modify/passthrough)
9
- * - after_tool_call hook — Session event capture
10
- * - command:new hook — Session initialization and cleanup
11
- * - session_start hook — Re-key DB session to OpenClaw's session ID
12
- * - before_compaction hook — Flush events to resume snapshot
13
- * - after_compaction hook — Increment compact count
14
- * - before_prompt_build (p=10) — Resume snapshot injection into system context
15
- * - before_prompt_build (p=5) — Routing instruction injection into system context
16
- * - context-mode engine — Context engine with compaction management
17
- * - /ctx-stats command — Auto-reply command for session statistics
18
- * - /ctx-doctor command — Auto-reply command for diagnostics
19
- * - /ctx-upgrade command — Auto-reply command for upgrade
20
- *
21
- * Loaded by OpenClaw via: openclaw.extensions entry in package.json
22
- *
23
- * OpenClaw plugin paradigm:
24
- * - Plugins export { id, name, configSchema, register(api) } for metadata
25
- * - api.registerHook() for event-driven hooks
26
- * - api.on() for typed lifecycle hooks
27
- * - api.registerContextEngine() for compaction ownership
28
- * - api.registerCommand() for auto-reply slash commands
29
- * - Plugins run in-process with the Gateway (trusted code)
30
- */
31
- import type { OpenClawToolDef } from "./openclaw/mcp-tools.js";
32
- /** Context for auto-reply command handlers. */
33
- interface CommandContext {
34
- senderId?: string;
35
- channel?: string;
36
- isAuthorizedSender?: boolean;
37
- args?: string;
38
- commandBody?: string;
39
- config?: Record<string, unknown>;
40
- }
41
- /** OpenClaw plugin API provided to the register function. */
42
- interface OpenClawPluginApi {
43
- registerHook(event: string, handler: (...args: unknown[]) => unknown, meta: {
44
- name: string;
45
- description: string;
46
- }): void;
47
- /**
48
- * Register a typed lifecycle hook.
49
- * Supported names: "session_start", "before_compaction", "after_compaction",
50
- * "before_prompt_build"
51
- */
52
- on(event: string, handler: (...args: unknown[]) => unknown, opts?: {
53
- priority?: number;
54
- }): void;
55
- registerContextEngine(id: string, factory: () => ContextEngineInstance): void;
56
- registerCommand?(cmd: {
57
- name: string;
58
- description: string;
59
- acceptsArgs?: boolean;
60
- requireAuth?: boolean;
61
- handler: (ctx: CommandContext) => {
62
- text: string;
63
- } | Promise<{
64
- text: string;
65
- }>;
66
- }): void;
67
- registerCli?(factory: (ctx: {
68
- program: unknown;
69
- }) => void, meta: {
70
- commands: string[];
71
- }): void;
72
- /**
73
- * Register an agent tool (OpenClaw native registerTool) — see
74
- * refs/platforms/openclaw/docs/plugins/building-plugins.md:116. Optional in
75
- * the type so we degrade silently on legacy hosts that pre-date this API.
76
- */
77
- registerTool?(tool: OpenClawToolDef, opts?: {
78
- optional?: boolean;
79
- }): void;
80
- logger?: {
81
- info: (...args: unknown[]) => void;
82
- error: (...args: unknown[]) => void;
83
- debug?: (...args: unknown[]) => void;
84
- warn?: (...args: unknown[]) => void;
85
- };
86
- }
87
- /** Context engine instance returned by the factory. */
88
- interface ContextEngineInstance {
89
- info: {
90
- id: string;
91
- name: string;
92
- ownsCompaction: boolean;
93
- };
94
- ingest(data: unknown): Promise<{
95
- ingested: boolean;
96
- }>;
97
- assemble(ctx: {
98
- messages: unknown[];
99
- }): Promise<{
100
- messages: unknown[];
101
- estimatedTokens: number;
102
- }>;
103
- compact(): Promise<{
104
- ok: boolean;
105
- compacted: boolean;
106
- }>;
107
- }
108
- /**
109
- * OpenClaw plugin definition. The object form provides declarative metadata
110
- * (id, name, configSchema) that OpenClaw can read without executing code.
111
- * register() is called once per agent session with a fresh api object.
112
- * Each call creates isolated closures (db, sessionId, hooks) — no shared state.
113
- */
114
- declare const _default: {
115
- id: string;
116
- name: string;
117
- configSchema: {
118
- type: "object";
119
- properties: {
120
- enabled: {
121
- type: "boolean";
122
- default: boolean;
123
- description: string;
124
- };
125
- };
126
- additionalProperties: boolean;
127
- };
128
- register(api: OpenClawPluginApi): void;
129
- };
130
- export default _default;