@opencow-ai/opencow-agent-sdk 0.4.26 → 0.4.28
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/dist/capabilities/mcp/types.d.ts +3 -0
- package/dist/capabilities/plugins/pluginOptionsStorage.d.ts +6 -0
- package/dist/capabilities/plugins/schemas.d.ts +6 -0
- package/dist/capabilities/plugins/sdkPluginRuntime.d.ts +2 -0
- package/dist/cli.mjs +228 -241
- package/dist/client.js +288 -257
- package/dist/constants/oauth.d.ts +0 -8
- package/dist/controller/compact/compact.d.ts +8 -2
- package/dist/controller/dispatch/toolHooks.d.ts +4 -3
- package/dist/controller/loop.d.ts +2 -1
- package/dist/entrypoints/sdk/controlSchemas.d.ts +25 -0
- package/dist/entrypoints/sdk/coreSchemas.d.ts +16 -0
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +21 -0
- package/dist/providers/shared/retry.d.ts +13 -1
- package/dist/sdk.js +288 -257
- package/dist/session/branding.d.ts +4 -0
- package/dist/session/brandingConfig.d.ts +16 -0
- package/dist/session/contextSnapshot.d.ts +14 -0
- package/dist/session/state/index.d.ts +1 -1
- package/dist/session/state/registries.d.ts +8 -1
- package/dist/session/state/types.d.ts +2 -0
- package/dist/types/contextSnapshot.d.ts +17 -0
- package/package.json +1 -1
- package/dist/capabilities/tools/AgentTool/built-in/claudeCodeGuideAgent.d.ts +0 -3
|
@@ -4,6 +4,10 @@ export declare function runWithBranding<T>(branding: ResolvedBranding, fn: () =>
|
|
|
4
4
|
export declare function getBranding(): ResolvedBranding;
|
|
5
5
|
export declare function getAssistantIdentityPrompt(): string;
|
|
6
6
|
export declare function getMcpClientInfo(): {
|
|
7
|
+
readonly name: string;
|
|
7
8
|
readonly title: string;
|
|
8
9
|
readonly description: string;
|
|
10
|
+
readonly websiteUrl?: string;
|
|
9
11
|
};
|
|
12
|
+
/** 第三方 MCP 服务器与网页抓取看到的 UA 前缀 */
|
|
13
|
+
export declare function getProductUserAgentToken(): string;
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
export interface BrandingOptions {
|
|
2
2
|
/** Product name shown in client display metadata and used as the assistant fallback. */
|
|
3
3
|
productName?: string;
|
|
4
|
+
/**
|
|
5
|
+
* ASCII identifier for User-Agent and MCP clientInfo.name. Derived from productName
|
|
6
|
+
* when omitted; hosts with non-ASCII names should set it explicitly.
|
|
7
|
+
*/
|
|
8
|
+
productSlug?: string;
|
|
4
9
|
/** Assistant identity used in model-facing prompts. Defaults to productName. */
|
|
5
10
|
assistantName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Host-hosted CIMD (SEP-991) client metadata URL for MCP OAuth. When omitted,
|
|
13
|
+
* the SDK does not send CIMD and MCP OAuth uses Dynamic Client Registration.
|
|
14
|
+
*/
|
|
15
|
+
mcpOAuthClientMetadataUrl?: string;
|
|
16
|
+
/** Product website reported to MCP servers as clientInfo.websiteUrl. Must be an absolute http(s) URL. */
|
|
17
|
+
productUrl?: string;
|
|
6
18
|
}
|
|
7
19
|
export interface ResolvedBranding {
|
|
8
20
|
readonly productName: string;
|
|
21
|
+
/** Lowercase identifier derived from productName; used in User-Agent and MCP clientInfo.name. */
|
|
22
|
+
readonly productSlug: string;
|
|
9
23
|
readonly assistantName: string;
|
|
24
|
+
readonly mcpOAuthClientMetadataUrl?: string;
|
|
25
|
+
readonly productUrl?: string;
|
|
10
26
|
}
|
|
11
27
|
export declare const DEFAULT_BRANDING: ResolvedBranding;
|
|
12
28
|
export declare function resolveBranding(options?: BrandingOptions): ResolvedBranding;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Message } from '../types/message.js';
|
|
2
|
+
import type { SDKContextSnapshot } from '../types/contextSnapshot.js';
|
|
3
|
+
export declare function buildContextSnapshot(messages: readonly Message[]): SDKContextSnapshot | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Validates a persisted snapshot and restores its token baseline marker.
|
|
6
|
+
*
|
|
7
|
+
* Invalid snapshots throw instead of silently falling back to a smaller
|
|
8
|
+
* context: a corrupt persisted snapshot is a host data problem that must be
|
|
9
|
+
* visible, not converted into a different model context.
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeContextSnapshot(raw: unknown): {
|
|
12
|
+
messages: Message[];
|
|
13
|
+
baselineTokens: number;
|
|
14
|
+
};
|
|
@@ -28,7 +28,7 @@ export { clearBetaHeaderLatches, getAfkModeHeaderLatched, getCacheEditingHeaderL
|
|
|
28
28
|
export { getAllowedChannels, getAllowedSettingSources, getClientType, getDirectConnectServerUrl, getFileSystemLayer, getFlagSettingsInline, getHasDevChannels, getIsNonInteractiveSession, getQueryEnvForSpawn, getQueryEnvOverrides, getHostProvidedEnvVar, getQueryEnvVar, getQuestionPreviewFormat, getRuntimeMode, getSdkBetas, getSessionSource, isInteractive, isRemoteMode, preferThirdPartyAuthentication, setAllowedChannels, setAllowedSettingSources, setDirectConnectServerUrl, setFlagSettingsInline, setHasDevChannels, setSdkBetas, } from './config.js';
|
|
29
29
|
export { deleteEnvVar, resolveEnvVar, setEnvVar, } from '../../constants/envVars.js';
|
|
30
30
|
export type { EnvVarKey } from '../../constants/envVars.js';
|
|
31
|
-
export { addInvokedSkill, clearInvokedSkills, clearInvokedSkillsForAgent, clearRegisteredHooks, clearRegisteredPluginHooks, clearSystemPromptSectionState, getAgentColorMap, getCachedClaudeMdContent, getInitJsonSchema, getInvokedSkills, getInvokedSkillsForAgent, getPlanSlugCache, getRegisteredHooks, getSystemPromptSectionCache, registerHookCallbacks, resetSdkInitState, setCachedClaudeMdContent, setExplicitPluginRuntimeContext, setInitJsonSchema, setSystemPromptSectionCacheEntry, tryGetExplicitPluginDataPath, tryGetSessionLspManager, } from './registries.js';
|
|
31
|
+
export { addInvokedSkill, clearInvokedSkills, clearInvokedSkillsForAgent, clearRegisteredHooks, clearRegisteredPluginHooks, clearSystemPromptSectionState, getAgentColorMap, getCachedClaudeMdContent, getInitJsonSchema, getInvokedSkills, getInvokedSkillsForAgent, getPlanSlugCache, getRegisteredHooks, getSystemPromptSectionCache, registerHookCallbacks, resetSdkInitState, setCachedClaudeMdContent, setExplicitPluginRuntimeBundle, setExplicitPluginRuntimeContext, setInitJsonSchema, setSystemPromptSectionCacheEntry, tryGetExplicitPluginDataPath, tryGetPluginContentVariables, tryGetSessionLspManager, } from './registries.js';
|
|
32
32
|
export { getProvider } from './provider.js';
|
|
33
33
|
export { addToInMemoryErrorLog, getInMemoryErrorLog, getLastEmittedDate, getTeleportedSessionInfo, handleAutoModeTransition, handlePlanModeTransition, hasExitedPlanModeInSession, hasShownLspRecommendationThisSession, markFirstTeleportMessageLogged, needsAutoModeExitAttachment, needsPlanModeExitAttachment, setHasExitedPlanMode, setLastEmittedDate, setLspRecommendationShownThisSession, setNeedsAutoModeExitAttachment, setNeedsPlanModeExitAttachment, setTeleportedSessionInfo, } from './diagnostics.js';
|
|
34
34
|
export { getFeatureFlags, getKairosActive, getScheduledTasksEnabled, getSdkAgentProgressSummariesEnabled, getSessionBypassPermissionsMode, getSessionTrustAccepted, getStrictToolResultPairing, getUserMsgOptIn, isSessionPersistenceDisabled, setScheduledTasksEnabled, } from './featureFlags.js';
|
|
@@ -45,7 +45,14 @@ export declare function setInitJsonSchema(schema: Record<string, unknown>): void
|
|
|
45
45
|
* hooks/hooksConfigSnapshot.ts before re-establishing the hook registry.
|
|
46
46
|
*/
|
|
47
47
|
export declare function resetSdkInitState(): void;
|
|
48
|
-
export declare function setExplicitPluginRuntimeContext(dataPaths: ReadonlyMap<string, string>, lspManager: LSPServerManager | null): void;
|
|
48
|
+
export declare function setExplicitPluginRuntimeContext(dataPaths: ReadonlyMap<string, string>, lspManager: LSPServerManager | null, contentVariables: Readonly<Record<string, string>>): void;
|
|
49
|
+
/** 会话装配插件 bundle 的唯一入口(sdkRuntime 与 SessionRuntime 共用),避免某一处漏传 contentVariables。 */
|
|
50
|
+
export declare function setExplicitPluginRuntimeBundle(bundle: {
|
|
51
|
+
readonly dataPaths: ReadonlyMap<string, string>;
|
|
52
|
+
readonly lspManager: LSPServerManager | null;
|
|
53
|
+
readonly contentVariables?: Readonly<Record<string, string>>;
|
|
54
|
+
}): void;
|
|
55
|
+
export declare function tryGetPluginContentVariables(): Readonly<Record<string, string>>;
|
|
49
56
|
export declare function tryGetExplicitPluginDataPath(pluginId: string): string | undefined;
|
|
50
57
|
export declare function tryGetSessionLspManager(): LSPServerManager | undefined;
|
|
51
58
|
export declare function addInvokedSkill(skillName: string, skillPath: string, content: string, agentId?: string | null): void;
|
|
@@ -288,6 +288,8 @@ export interface QueryRegistries {
|
|
|
288
288
|
dynamicSkills: import('../../capabilities/skills/loadSkillsDir.js').DynamicSkillsState;
|
|
289
289
|
/** Host-managed plugin data roots keyed by stable plugin id. */
|
|
290
290
|
pluginDataPaths: Map<string, string>;
|
|
291
|
+
/** Host-defined `${NAME}` values for managed plugin skill / command bodies. */
|
|
292
|
+
pluginContentVariables: Readonly<Record<string, string>>;
|
|
291
293
|
/** Session-scoped LSP manager for explicit SDK plugins; null uses CLI fallback. */
|
|
292
294
|
lspManager: import('../../capabilities/lsp/LSPServerManager.js').LSPServerManager | null;
|
|
293
295
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versioned, host-persistable snapshot of the post-compact model context.
|
|
3
|
+
*
|
|
4
|
+
* `messages` intentionally stays opaque at the public boundary: the SDK owns
|
|
5
|
+
* the internal canonical message shapes, while hosts only persist and return
|
|
6
|
+
* the snapshot unchanged.
|
|
7
|
+
*/
|
|
8
|
+
export type SDKContextSnapshot = {
|
|
9
|
+
schemaVersion: 1;
|
|
10
|
+
messages: readonly unknown[];
|
|
11
|
+
/**
|
|
12
|
+
* Estimated or API-reported size of `messages` at snapshot creation time.
|
|
13
|
+
* Used as the context baseline until a later assistant response carries real
|
|
14
|
+
* usage.
|
|
15
|
+
*/
|
|
16
|
+
baselineTokens: number;
|
|
17
|
+
};
|
package/package.json
CHANGED