@native-marketing/sdk 0.3.6 → 0.3.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/package.json CHANGED
@@ -1,11 +1,21 @@
1
1
  {
2
2
  "name": "@native-marketing/sdk",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "engines": {
7
7
  "node": ">=24 <25"
8
8
  },
9
+ "nativeMarketing": {
10
+ "contractVersion": 1,
11
+ "apiMajor": 1,
12
+ "nodeMajor": 24,
13
+ "changes": [
14
+ "Unified SDK, CLI and MCP release discovery and compatibility checks.",
15
+ "Configurable CLI update notifications, pins and compatible automatic updates.",
16
+ "Upgrade verification and explicit continuation without replaying business commands."
17
+ ]
18
+ },
9
19
  "publishConfig": {
10
20
  "access": "public",
11
21
  "registry": "https://registry.npmjs.org/"
package/release.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
- "sourceCommit": "40463e01d4112b05570b24ec7da538ed5f489d0d",
2
+ "sourceCommit": "170f43ed793abd2cee15faaba49428aa43c276cd",
3
3
  "workingTreeDirty": false,
4
- "version": "0.3.6",
4
+ "version": "0.3.7",
5
5
  "openapiTypesSha256": "e79e0abf034cae01174e67464aea55f16d40895c86199eff93897ec892ea82f4",
6
6
  "localBuild": true
7
7
  }
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod';
2
+ export { nativeClientRelease } from './generated/client-release.js';
3
+ export declare const nativeReleaseCapability = "com.native-marketing/client-release";
4
+ export declare const releaseVersionSchema: z.ZodString;
5
+ export declare const clientIdentitySchema: z.ZodObject<{
6
+ version: z.ZodString;
7
+ contractVersion: z.ZodNumber;
8
+ apiMajor: z.ZodNumber;
9
+ }, z.core.$strip>;
10
+ export declare const clientReleaseSchema: z.ZodObject<{
11
+ schemaVersion: z.ZodLiteral<1>;
12
+ product: z.ZodLiteral<"native-marketing">;
13
+ version: z.ZodString;
14
+ packages: z.ZodObject<{
15
+ sdk: z.ZodLiteral<"@native-marketing/sdk">;
16
+ cli: z.ZodLiteral<"@native-marketing/cli">;
17
+ }, z.core.$strip>;
18
+ contractVersion: z.ZodNumber;
19
+ minimumClientVersion: z.ZodString;
20
+ apiMajor: z.ZodNumber;
21
+ nodeMajor: z.ZodNumber;
22
+ changes: z.ZodDefault<z.ZodArray<z.ZodString>>;
23
+ }, z.core.$strip>;
24
+ export declare const updatePolicySchema: z.ZodObject<{
25
+ mode: z.ZodDefault<z.ZodEnum<{
26
+ auto: "auto";
27
+ notify: "notify";
28
+ off: "off";
29
+ }>>;
30
+ channel: z.ZodDefault<z.ZodEnum<{
31
+ beta: "beta";
32
+ latest: "latest";
33
+ next: "next";
34
+ }>>;
35
+ pin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
36
+ intervalHours: z.ZodDefault<z.ZodNumber>;
37
+ }, z.core.$strict>;
38
+ export declare const defaultUpdatePolicy: {
39
+ mode: "auto" | "notify" | "off";
40
+ channel: "beta" | "latest" | "next";
41
+ pin: string | null;
42
+ intervalHours: number;
43
+ };
44
+ export type NativeClientIdentity = z.infer<typeof clientIdentitySchema>;
45
+ export type NativeClientRelease = z.infer<typeof clientReleaseSchema>;
46
+ export type NativeUpdatePolicy = z.infer<typeof updatePolicySchema>;
47
+ export interface NativeCompatibility {
48
+ status: 'COMPATIBLE' | 'UPGRADE_RECOMMENDED' | 'INCOMPATIBLE' | 'UNKNOWN';
49
+ reason: 'CURRENT' | 'NEWER_CLIENT_AVAILABLE' | 'CLIENT_TOO_OLD' | 'CONTRACT_MISMATCH' | 'API_MISMATCH' | 'SERVER_METADATA_UNAVAILABLE';
50
+ client: NativeClientIdentity;
51
+ server: NativeClientRelease | null;
52
+ }
53
+ /** Exact SemVer precedence only; package-manager ranges are never interpreted here. */
54
+ export declare function compareReleaseVersions(left: string, right: string): number;
55
+ export declare function assessNativeCompatibility(client: NativeClientIdentity, server?: NativeClientRelease): NativeCompatibility;
@@ -0,0 +1,84 @@
1
+ import { z } from 'zod';
2
+ import { type NativeClientRelease, type NativeUpdatePolicy } from './client-lifecycle.js';
3
+ export declare const registryReleaseSchema: z.ZodObject<{
4
+ name: z.ZodEnum<{
5
+ "@native-marketing/cli": "@native-marketing/cli";
6
+ "@native-marketing/sdk": "@native-marketing/sdk";
7
+ }>;
8
+ version: z.ZodString;
9
+ deprecated: z.ZodOptional<z.ZodString>;
10
+ nativeMarketing: z.ZodOptional<z.ZodObject<{
11
+ contractVersion: z.ZodNumber;
12
+ apiMajor: z.ZodNumber;
13
+ nodeMajor: z.ZodNumber;
14
+ changes: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
+ }, z.core.$strip>>;
16
+ dist: z.ZodObject<{
17
+ integrity: z.ZodString;
18
+ }, z.core.$strip>;
19
+ }, z.core.$strip>;
20
+ export type NativeRegistryRelease = z.infer<typeof registryReleaseSchema>;
21
+ export declare const clientUpdateStateSchema: z.ZodObject<{
22
+ schemaVersion: z.ZodLiteral<1>;
23
+ policy: z.ZodObject<{
24
+ mode: z.ZodDefault<z.ZodEnum<{
25
+ auto: "auto";
26
+ notify: "notify";
27
+ off: "off";
28
+ }>>;
29
+ channel: z.ZodDefault<z.ZodEnum<{
30
+ beta: "beta";
31
+ latest: "latest";
32
+ next: "next";
33
+ }>>;
34
+ pin: z.ZodDefault<z.ZodNullable<z.ZodString>>;
35
+ intervalHours: z.ZodDefault<z.ZodNumber>;
36
+ }, z.core.$strict>;
37
+ lastCheck: z.ZodOptional<z.ZodObject<{
38
+ at: z.ZodNumber;
39
+ selector: z.ZodString;
40
+ target: z.ZodObject<{
41
+ name: z.ZodEnum<{
42
+ "@native-marketing/cli": "@native-marketing/cli";
43
+ "@native-marketing/sdk": "@native-marketing/sdk";
44
+ }>;
45
+ version: z.ZodString;
46
+ deprecated: z.ZodOptional<z.ZodString>;
47
+ nativeMarketing: z.ZodOptional<z.ZodObject<{
48
+ contractVersion: z.ZodNumber;
49
+ apiMajor: z.ZodNumber;
50
+ nodeMajor: z.ZodNumber;
51
+ changes: z.ZodOptional<z.ZodArray<z.ZodString>>;
52
+ }, z.core.$strip>>;
53
+ dist: z.ZodObject<{
54
+ integrity: z.ZodString;
55
+ }, z.core.$strip>;
56
+ }, z.core.$strip>;
57
+ }, z.core.$strict>>;
58
+ lastAttempt: z.ZodOptional<z.ZodObject<{
59
+ at: z.ZodNumber;
60
+ selector: z.ZodString;
61
+ }, z.core.$strict>>;
62
+ }, z.core.$strict>;
63
+ export type NativeClientUpdateState = z.infer<typeof clientUpdateStateSchema>;
64
+ export interface NativeUpdatePlan {
65
+ package: NativeRegistryRelease['name'];
66
+ currentVersion: string;
67
+ targetVersion: string;
68
+ status: 'CURRENT' | 'UPDATE_AVAILABLE' | 'BLOCKED';
69
+ reason: 'CURRENT' | 'COMPATIBLE_UPDATE' | 'REVIEW_REQUIRED' | 'PIN_MISMATCH' | 'CHANNEL_MISMATCH' | 'DOWNGRADE_FORBIDDEN' | 'METADATA_UNAVAILABLE' | 'CONTRACT_MISMATCH' | 'NODE_MISMATCH' | 'SERVER_INCOMPATIBLE' | 'DEPRECATED';
70
+ eligibleForAutoUpdate: boolean;
71
+ policy: NativeUpdatePolicy;
72
+ commands: {
73
+ npm: string[];
74
+ pnpm: string[];
75
+ yarn: string[] | null;
76
+ };
77
+ }
78
+ export declare function planNativeUpdate(input: {
79
+ target: NativeRegistryRelease;
80
+ currentVersion?: string;
81
+ policy?: NativeUpdatePolicy;
82
+ nodeMajor?: number;
83
+ server?: NativeClientRelease;
84
+ }): NativeUpdatePlan;
@@ -0,0 +1,14 @@
1
+ export declare const nativeClientRelease: {
2
+ readonly schemaVersion: 1;
3
+ readonly product: 'native-marketing';
4
+ readonly version: '0.3.7';
5
+ readonly packages: {
6
+ readonly sdk: '@native-marketing/sdk';
7
+ readonly cli: '@native-marketing/cli';
8
+ };
9
+ readonly contractVersion: 1;
10
+ readonly minimumClientVersion: '0.3.6';
11
+ readonly apiMajor: 1;
12
+ readonly nodeMajor: 24;
13
+ readonly changes: readonly ['Unified SDK, CLI and MCP release discovery and compatibility checks.', 'Configurable CLI update notifications, pins and compatible automatic updates.', 'Upgrade verification and explicit continuation without replaying business commands.'];
14
+ };
@@ -117,3 +117,5 @@ export * from './event-backlog.js';
117
117
  export * from './event-readiness.js';
118
118
  export * from './event-inbox.js';
119
119
  export * from './event-outbox-browser.js';
120
+ export * from './client-lifecycle.js';
121
+ export * from './client-update-policy.js';
@@ -0,0 +1,35 @@
1
+ import type { ContentFactoryClientOptions } from './client.js';
2
+ export declare function getNativeClientVersion(): {
3
+ schemaVersion: 1;
4
+ product: "native-marketing";
5
+ version: string;
6
+ packages: {
7
+ sdk: "@native-marketing/sdk";
8
+ cli: "@native-marketing/cli";
9
+ };
10
+ contractVersion: number;
11
+ minimumClientVersion: string;
12
+ apiMajor: number;
13
+ nodeMajor: number;
14
+ changes: string[];
15
+ };
16
+ export declare function checkNativeHttpVersion(options?: ContentFactoryClientOptions & {
17
+ timeoutMs?: number;
18
+ requireCompatibility?: boolean;
19
+ }): Promise<{
20
+ client: {
21
+ schemaVersion: 1;
22
+ product: "native-marketing";
23
+ version: string;
24
+ packages: {
25
+ sdk: "@native-marketing/sdk";
26
+ cli: "@native-marketing/cli";
27
+ };
28
+ contractVersion: number;
29
+ minimumClientVersion: string;
30
+ apiMajor: number;
31
+ nodeMajor: number;
32
+ changes: string[];
33
+ };
34
+ compatibility: import("../contracts/index.js").NativeCompatibility;
35
+ }>;
@@ -2,6 +2,7 @@ import type { paths } from './generated/schema.js';
2
2
  export interface ContentFactoryClientOptions {
3
3
  baseUrl?: string;
4
4
  fetch?: (input: Request) => Promise<Response>;
5
+ compatibility?: 'check' | 'require';
5
6
  }
6
7
  /** 共用认证HTTP入口,空写动作与生产代理保持一致的JSON传输合同。 */
7
8
  export declare function createContentFactoryClient(options?: ContentFactoryClientOptions): import("openapi-fetch").Client<paths, `${string}/${string}`>;
@@ -1,4 +1,6 @@
1
1
  export { createContentFactoryClient } from './client.js';
2
+ export { getNativeClientVersion, checkNativeHttpVersion } from './client-version.js';
3
+ export { assessNativeCompatibility, planNativeUpdate, defaultUpdatePolicy, type NativeClientRelease, type NativeClientIdentity, type NativeRegistryRelease, type NativeCompatibility, type NativeUpdatePolicy, type NativeUpdatePlan, } from '../contracts/index.js';
2
4
  export { readingDocument } from '../contracts/index.js';
3
5
  export { programActivationRequirements } from '../contracts/index.js';
4
6
  export type { ProjectAccessView, ProjectAccessChange } from '../contracts/index.js';
@@ -3,6 +3,7 @@ export declare function verifyCapabilityDefinition(raw: unknown, name: string, e
3
3
  /** Per connection metadata only. A cache hit is never permission to execute. */
4
4
  export declare class CapabilityDefinitionCache {
5
5
  private readonly values;
6
+ clear(): void;
6
7
  remember(value: CapabilityDefinition): void;
7
8
  get(name: string, hash: string): {
8
9
  schemaVersion: 1;
@@ -2,6 +2,7 @@
2
2
  export declare function runNetworkCli(args: string[], env?: NodeJS.ProcessEnv, io?: {
3
3
  stdin?: AsyncIterable<string | Uint8Array>;
4
4
  notify?: (message: string) => void;
5
+ executablePath?: string;
5
6
  }, executable?: 'cf' | 'cf-agent'): Promise<{
6
7
  exitCode: number;
7
8
  envelope: {
@@ -4,7 +4,10 @@ import { uploadNativeProjectMedia, uploadNativeMaterial, type NativeMaterialUplo
4
4
  import type { BusinessDocumentInput, AgentSummaryInput, AgentSummary, CapabilityCall, BusinessSearchQuery, BusinessSearchPage, BusinessContentPageRead, BusinessContentPage, CapabilityQuery, CapabilityPage, AgentCapabilityPage, CapabilityDefinition, CapabilitySchemaRead, BusinessDocumentPage } from '../contracts/index.js';
5
5
  import { readNativeCapabilityDescriptor, readNativeCapabilitySchemaPage } from './schema-pages.js';
6
6
  import { inspectNativeTool, listNativeToolsPage, type NativeToolOptions, type NativeToolResult } from './operations.js';
7
+ import { readNativeServerVersion } from './updates/version.js';
7
8
  export interface NativeAgentClient {
9
+ getVersion(): ReturnType<typeof readNativeServerVersion>;
10
+ refreshVersion(): Promise<ReturnType<typeof readNativeServerVersion>>;
8
11
  readPackageFile(input: Parameters<typeof readNativePackageFile>[1]): ReturnType<typeof readNativePackageFile>;
9
12
  readProjectMediaFile(input: Parameters<typeof readNativeProjectMediaFile>[1]): ReturnType<typeof readNativeProjectMediaFile>;
10
13
  uploadProjectMedia(file: Parameters<typeof uploadNativeProjectMedia>[1]): ReturnType<typeof uploadNativeProjectMedia>;
@@ -32,4 +35,6 @@ export declare function withNativeAgentClient<T>(connection: {
32
35
  accessToken: string;
33
36
  }, action: (client: NativeAgentClient) => Promise<T>, options?: {
34
37
  timeoutMs?: number;
38
+ requireCompatibility?: boolean;
39
+ onVersion?: (version: ReturnType<typeof readNativeServerVersion>) => void;
35
40
  }): Promise<T>;
@@ -17,3 +17,6 @@ export type { CapabilitySchemaRead, CapabilitySchemaPage } from '../contracts/in
17
17
  export { uploadNativeProjectMedia, uploadNativeMaterial, type NativeMaterialUpload, } from './material-upload.js';
18
18
  export { readNativeProjectMediaFile, projectMediaFileQuerySchema } from './project-media.js';
19
19
  export { readNativePackageFile } from './package-files.js';
20
+ export { getNativeClientVersion } from './updates/version.js';
21
+ export { checkNativeUpdates } from './updates/registry.js';
22
+ export { assessNativeCompatibility, planNativeUpdate, defaultUpdatePolicy, type NativeClientRelease, type NativeClientIdentity, type NativeRegistryRelease, type NativeCompatibility, type NativeUpdatePolicy, type NativeUpdatePlan, } from '../contracts/index.js';
@@ -1,5 +1,10 @@
1
1
  import { Client, type Tool } from '@modelcontextprotocol/client';
2
2
  import { type Profile } from './profile.js';
3
+ import { readNativeServerVersion } from './updates/version.js';
3
4
  /** 只访问远端正式工具;无本地数据库 fallback,也不重试未知结果的写操作。 */
4
- export declare function withClient<T>(profile: Profile, timeout: number, operation: (client: Client) => Promise<T>): Promise<T>;
5
+ export declare function withClient<T>(profile: Profile, timeout: number, operation: (client: Client) => Promise<T>, options?: {
6
+ requireCompatibility?: boolean;
7
+ allowIncompatible?: boolean;
8
+ onVersion?: (version: ReturnType<typeof readNativeServerVersion>) => void;
9
+ }): Promise<T>;
5
10
  export declare function callTool(client: Client, tool: Tool, input: Record<string, unknown>, timeout: number, readOnly: boolean, errorToolName?: string): Promise<unknown>;
@@ -0,0 +1,11 @@
1
+ import type { ParsedArgs } from '../cli/input.js';
2
+ type Output = {
3
+ command: string;
4
+ data: unknown;
5
+ };
6
+ export declare function runLifecycleCommand(parsed: ParsedArgs, env: NodeJS.ProcessEnv, executablePath?: string): Promise<Output | null>;
7
+ export declare function maybeAutoUpdate(env: NodeJS.ProcessEnv, io: {
8
+ executablePath?: string;
9
+ notify?: (message: string) => void;
10
+ }, timeout: number): Promise<Output | null>;
11
+ export {};
@@ -0,0 +1,20 @@
1
+ import { type NativeRegistryRelease, type NativeUpdatePolicy } from '../../contracts/index.js';
2
+ /** The only subprocess adapter in the client: fixed npm installation and version verification. */
3
+ export declare function installCliUpdate(input: {
4
+ target: NativeRegistryRelease;
5
+ currentVersion?: string;
6
+ policy: NativeUpdatePolicy;
7
+ executablePath?: string;
8
+ allowBreaking?: boolean;
9
+ automatic?: boolean;
10
+ timeoutMs: number;
11
+ env: NodeJS.ProcessEnv;
12
+ }): Promise<{
13
+ state: string;
14
+ package: "@native-marketing/cli" | "@native-marketing/sdk";
15
+ previousVersion: string;
16
+ installedVersion: string;
17
+ restartRequired: boolean;
18
+ originalCommandExecuted: boolean;
19
+ recovery: string[];
20
+ }>;
@@ -0,0 +1,26 @@
1
+ import { type NativeClientRelease, type NativeUpdatePolicy } from '../../contracts/index.js';
2
+ export declare function checkNativeUpdates(options?: {
3
+ package?: 'sdk' | 'cli';
4
+ currentVersion?: string;
5
+ policy?: NativeUpdatePolicy;
6
+ server?: NativeClientRelease;
7
+ timeoutMs?: number;
8
+ fetch?: typeof fetch;
9
+ }): Promise<{
10
+ checkedAt: number;
11
+ target: {
12
+ name: "@native-marketing/cli" | "@native-marketing/sdk";
13
+ version: string;
14
+ deprecated?: string | undefined;
15
+ nativeMarketing?: {
16
+ contractVersion: number;
17
+ apiMajor: number;
18
+ nodeMajor: number;
19
+ changes?: string[] | undefined;
20
+ } | undefined;
21
+ dist: {
22
+ integrity: string;
23
+ };
24
+ };
25
+ plan: import("../../contracts/index.js").NativeUpdatePlan;
26
+ }>;
@@ -0,0 +1,14 @@
1
+ import { type NativeClientUpdateState as State, type NativeUpdatePolicy } from '../../contracts/index.js';
2
+ export declare class UpdateStore {
3
+ private readonly files;
4
+ constructor(env: NodeJS.ProcessEnv);
5
+ read(): Promise<State>;
6
+ locked<T>(action: () => Promise<T>): Promise<T>;
7
+ change(action: (state: State) => State): Promise<State>;
8
+ }
9
+ export declare function effectiveUpdatePolicy(policy: NativeUpdatePolicy, env: NodeJS.ProcessEnv): {
10
+ mode: "auto" | "notify" | "off";
11
+ channel: "beta" | "latest" | "next";
12
+ pin: string | null;
13
+ intervalHours: number;
14
+ };
@@ -0,0 +1,93 @@
1
+ import type { Client } from '@modelcontextprotocol/client';
2
+ export declare function getNativeClientVersion(): {
3
+ schemaVersion: 1;
4
+ product: "native-marketing";
5
+ version: string;
6
+ packages: {
7
+ sdk: "@native-marketing/sdk";
8
+ cli: "@native-marketing/cli";
9
+ };
10
+ contractVersion: number;
11
+ minimumClientVersion: string;
12
+ apiMajor: number;
13
+ nodeMajor: number;
14
+ changes: string[];
15
+ };
16
+ export declare function getNativeCliVersion(executablePath?: string): Promise<{
17
+ schemaVersion: 1;
18
+ product: "native-marketing";
19
+ version: string;
20
+ packages: {
21
+ sdk: "@native-marketing/sdk";
22
+ cli: "@native-marketing/cli";
23
+ };
24
+ contractVersion: number;
25
+ minimumClientVersion: string;
26
+ apiMajor: number;
27
+ nodeMajor: number;
28
+ changes: string[];
29
+ sdkVersion: "0.3.7";
30
+ }>;
31
+ export declare function readNativeServerVersion(client: Client): {
32
+ client: {
33
+ schemaVersion: 1;
34
+ product: "native-marketing";
35
+ version: string;
36
+ packages: {
37
+ sdk: "@native-marketing/sdk";
38
+ cli: "@native-marketing/cli";
39
+ };
40
+ contractVersion: number;
41
+ minimumClientVersion: string;
42
+ apiMajor: number;
43
+ nodeMajor: number;
44
+ changes: string[];
45
+ };
46
+ serverInfo: {
47
+ version: string;
48
+ websiteUrl?: string | undefined;
49
+ description?: string | undefined;
50
+ icons?: {
51
+ src: string;
52
+ mimeType?: string | undefined;
53
+ sizes?: string[] | undefined;
54
+ theme?: "dark" | "light" | undefined;
55
+ }[] | undefined;
56
+ name: string;
57
+ title?: string | undefined;
58
+ } | null;
59
+ mcpProtocolVersion: string | null;
60
+ compatibility: import("../../contracts/index.js").NativeCompatibility;
61
+ };
62
+ export declare function assertNativeCompatibility(result: ReturnType<typeof readNativeServerVersion>, required?: boolean): void;
63
+ export declare function refreshNativeServerVersion(client: Client, timeout: number): Promise<{
64
+ client: {
65
+ schemaVersion: 1;
66
+ product: "native-marketing";
67
+ version: string;
68
+ packages: {
69
+ sdk: "@native-marketing/sdk";
70
+ cli: "@native-marketing/cli";
71
+ };
72
+ contractVersion: number;
73
+ minimumClientVersion: string;
74
+ apiMajor: number;
75
+ nodeMajor: number;
76
+ changes: string[];
77
+ };
78
+ serverInfo: {
79
+ version: string;
80
+ websiteUrl?: string | undefined;
81
+ description?: string | undefined;
82
+ icons?: {
83
+ src: string;
84
+ mimeType?: string | undefined;
85
+ sizes?: string[] | undefined;
86
+ theme?: "dark" | "light" | undefined;
87
+ }[] | undefined;
88
+ name: string;
89
+ title?: string | undefined;
90
+ } | null;
91
+ mcpProtocolVersion: string | null;
92
+ compatibility: import("../../contracts/index.js").NativeCompatibility;
93
+ }>;