@s_s/agent-kit 1.0.0 → 1.2.0
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 +154 -79
- package/build/create-kit.js +6 -3
- package/build/create-kit.js.map +1 -1
- package/build/define-hooks.d.ts +31 -0
- package/build/define-hooks.js +192 -0
- package/build/define-hooks.js.map +1 -0
- package/build/hooks.d.ts +8 -5
- package/build/hooks.js +117 -119
- package/build/hooks.js.map +1 -1
- package/build/index.d.ts +4 -6
- package/build/index.js +6 -5
- package/build/index.js.map +1 -1
- package/build/paths.d.ts +31 -0
- package/build/paths.js +119 -0
- package/build/paths.js.map +1 -0
- package/build/prompt.d.ts +4 -0
- package/build/prompt.js +10 -19
- package/build/prompt.js.map +1 -1
- package/build/types.d.ts +66 -13
- package/build/types.js.map +1 -1
- package/package.json +1 -1
package/build/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAC9B,IAAY,EACZ,MAAc,EACd,KAAgB,EAChB,OAAsB;IAEtB,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAEpE,wBAAwB;IACxB,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,IAAI,CAAC;QACD,eAAe,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EA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AK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC5B,MAAM,KAAK,GAAG,GAAG,KAAK,KAAK,aAAa,KAAK,GAAG,EAAE,CAAC;IAEnD,IAAI,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,yBAAyB;QACzB,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QACpF,OAAO,eAAe,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;IAED,gBAAgB;IAChB,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,OAAO,eAAe,CAAC,OAAO,EAAE,GAAG,SAAS,GAAG,KAAK,GAAG,IAAI,CAAC;AAChE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAgB,EAAE,OAAsB;IACtE,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACpE,OAAO,UAAU,CAAC;AACtB,CAAC"}
|
package/build/types.d.ts
CHANGED
|
@@ -45,8 +45,8 @@ export interface Kit {
|
|
|
45
45
|
injectPrompt(agent: AgentType, prompt: string, options?: ScopeOptions): Promise<void>;
|
|
46
46
|
/** Check if prompt has been injected. */
|
|
47
47
|
hasPromptInjected(agent: AgentType, options?: ScopeOptions): Promise<boolean>;
|
|
48
|
-
/** Install hooks for the given agent. */
|
|
49
|
-
installHooks(agent: AgentType): Promise<HookInstallResult>;
|
|
48
|
+
/** Install hooks for the given agent. Accepts one or more HookSet from defineHooks(). */
|
|
49
|
+
installHooks(agent: AgentType, hooks: HookSet | HookSet[]): Promise<HookInstallResult>;
|
|
50
50
|
/** Uninstall hooks for the given agent. */
|
|
51
51
|
uninstallHooks(agent: AgentType): Promise<{
|
|
52
52
|
success: boolean;
|
|
@@ -57,17 +57,49 @@ export interface Kit {
|
|
|
57
57
|
hasHooksInstalled(agent: AgentType): Promise<boolean>;
|
|
58
58
|
/** Get platform-appropriate data directory path. */
|
|
59
59
|
getDataDir(options?: ScopeOptions): string;
|
|
60
|
+
/** Resolve all relevant paths (config file, hook dir, settings file) for an agent. */
|
|
61
|
+
resolvePaths(agent: AgentType, options?: ScopeOptions): AgentPaths;
|
|
60
62
|
}
|
|
63
|
+
/** Claude Code / Codex native hook event names. */
|
|
64
|
+
export type ClaudeCodeEvent = 'SessionStart' | 'InstructionsLoaded' | 'UserPromptSubmit' | 'PreToolUse' | 'PermissionRequest' | 'PostToolUse' | 'PostToolUseFailure' | 'Notification' | 'SubagentStart' | 'SubagentStop' | 'Stop' | 'TeammateIdle' | 'TaskCompleted' | 'ConfigChange' | 'WorktreeCreate' | 'WorktreeRemove' | 'PreCompact' | 'PostCompact' | 'Elicitation' | 'ElicitationResult' | 'SessionEnd';
|
|
65
|
+
/** OpenCode native hook event names. */
|
|
66
|
+
export type OpenCodeEvent = 'event' | 'config' | 'tool' | 'auth' | 'chat.message' | 'chat.params' | 'chat.headers' | 'permission.ask' | 'command.execute.before' | 'tool.execute.before' | 'shell.env' | 'tool.execute.after' | 'experimental.chat.messages.transform' | 'experimental.chat.system.transform' | 'experimental.session.compacting' | 'experimental.text.complete' | 'tool.definition';
|
|
67
|
+
/** OpenClaw plugin hook event names. */
|
|
68
|
+
export type OpenClawPluginEvent = 'before_model_resolve' | 'before_prompt_build' | 'before_agent_start' | 'llm_input' | 'llm_output' | 'agent_end' | 'before_compaction' | 'after_compaction' | 'before_reset' | 'message_received' | 'message_sending' | 'message_sent' | 'before_tool_call' | 'after_tool_call' | 'tool_result_persist' | 'before_message_write' | 'session_start' | 'session_end' | 'subagent_spawning' | 'subagent_delivery_target' | 'subagent_spawned' | 'subagent_ended' | 'gateway_start' | 'gateway_stop';
|
|
69
|
+
/** OpenClaw internal hook event names (type:action). */
|
|
70
|
+
export type OpenClawInternalEvent = 'command:new' | 'command:reset' | 'command:stop' | 'session:compact:before' | 'session:compact:after' | 'agent:bootstrap' | 'gateway:startup' | 'message:received' | 'message:sent' | 'message:transcribed' | 'message:preprocessed';
|
|
71
|
+
/** All OpenClaw hook event names (plugin + internal). */
|
|
72
|
+
export type OpenClawEvent = OpenClawPluginEvent | OpenClawInternalEvent;
|
|
73
|
+
/** Map from agent type to its event name union. */
|
|
74
|
+
export type AgentEventMap = {
|
|
75
|
+
'claude-code': ClaudeCodeEvent;
|
|
76
|
+
codex: ClaudeCodeEvent;
|
|
77
|
+
opencode: OpenCodeEvent;
|
|
78
|
+
openclaw: OpenClawEvent;
|
|
79
|
+
};
|
|
61
80
|
/**
|
|
62
|
-
*
|
|
81
|
+
* A single hook definition for a specific agent.
|
|
82
|
+
*
|
|
83
|
+
* - `events`: one or more native event names for this agent.
|
|
84
|
+
* - `content`: the hook content (shell script, TypeScript code, handler.ts body, etc.).
|
|
85
|
+
* Users are fully responsible for the content — agent-kit only writes it to the correct path.
|
|
86
|
+
* - `description`: (OpenClaw only) human-readable description for HOOK.md. Defaults to auto-generated.
|
|
63
87
|
*/
|
|
64
|
-
export interface
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
export interface HookDefinition<A extends AgentType = AgentType> {
|
|
89
|
+
events: A extends keyof AgentEventMap ? AgentEventMap[A][] : string[];
|
|
90
|
+
content: string;
|
|
91
|
+
/** OpenClaw only — description for HOOK.md. Ignored by other agents. */
|
|
92
|
+
description?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A validated set of hook definitions for a specific agent, returned by defineHooks().
|
|
96
|
+
* This is an opaque token — users should not construct it directly.
|
|
97
|
+
*/
|
|
98
|
+
export interface HookSet<A extends AgentType = AgentType> {
|
|
99
|
+
/** @internal brand field */
|
|
100
|
+
readonly __brand: 'HookSet';
|
|
101
|
+
readonly agent: A;
|
|
102
|
+
readonly definitions: readonly HookDefinition<A>[];
|
|
71
103
|
}
|
|
72
104
|
/**
|
|
73
105
|
* Result of hook installation.
|
|
@@ -78,10 +110,7 @@ export interface HookInstallResult {
|
|
|
78
110
|
filesWritten: string[];
|
|
79
111
|
settingsUpdated: boolean;
|
|
80
112
|
notes: string[];
|
|
81
|
-
/** Degradation and conflict warnings (e.g. raw overrides, partial support). */
|
|
82
113
|
warnings: string[];
|
|
83
|
-
/** Intents that were completely skipped for this agent. */
|
|
84
|
-
skipped: SkippedIntent[];
|
|
85
114
|
error?: string;
|
|
86
115
|
}
|
|
87
116
|
/**
|
|
@@ -101,6 +130,30 @@ export interface AgentRegistryEntry {
|
|
|
101
130
|
/** File paths to check for agent detection */
|
|
102
131
|
detectionPaths: (cwd: string, home: string) => string[];
|
|
103
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Resolved paths for an agent at a given scope.
|
|
135
|
+
*
|
|
136
|
+
* Returned by `kit.resolvePaths()` and `resolveAgentPaths()`.
|
|
137
|
+
*/
|
|
138
|
+
export interface AgentPaths {
|
|
139
|
+
/** Absolute path to the agent config file (e.g. AGENTS.md, CLAUDE.md). */
|
|
140
|
+
configFile: string;
|
|
141
|
+
/** Absolute path to the hook directory. Only present when `toolName` is provided (or via kit.resolvePaths). */
|
|
142
|
+
hookDir?: string;
|
|
143
|
+
/** Absolute path to the agent settings file (e.g. settings.json). Only present for agents that use one (claude-code, codex). */
|
|
144
|
+
settingsFile?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Options for the standalone `resolveAgentPaths()` function.
|
|
148
|
+
*/
|
|
149
|
+
export interface ResolveAgentPathsOptions {
|
|
150
|
+
/** Storage scope. Defaults to 'global'. */
|
|
151
|
+
scope?: StorageScope;
|
|
152
|
+
/** Required when scope is 'project'. */
|
|
153
|
+
projectRoot?: string;
|
|
154
|
+
/** Tool/kit name. Required to resolve hookDir. */
|
|
155
|
+
toolName?: string;
|
|
156
|
+
}
|
|
104
157
|
/**
|
|
105
158
|
* Map from MCP clientInfo.name to AgentType.
|
|
106
159
|
*/
|
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAyPrF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA8B;IACtD,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,aAAa;IAC5B,qBAAqB,EAAE,UAAU;IACjC,kBAAkB,EAAE,OAAO;CAC9B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAA0C;IACjE,QAAQ,EAAE;QACN,cAAc,EAAE,WAAW;QAC3B,gBAAgB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,6BAA6B;QAChE,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,YAAY;QAC9C,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,IAAI,2BAA2B;QACnE,cAAc,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;YAC3B,GAAG,GAAG,gBAAgB;YACtB,GAAG,GAAG,iBAAiB;YACvB,GAAG,IAAI,iCAAiC;SAC3C;KACJ;IACD,aAAa,EAAE;QACX,cAAc,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