@native-engagement/sdk 0.9.0 → 0.10.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/LICENSE +202 -0
- package/THIRD_PARTY_LICENSES.txt +117 -0
- package/dist/index.d.ts +838 -37
- package/dist/index.js +8 -1
- package/package.json +3 -9
- package/release.json +22 -2
- package/README.md +0 -141
package/package.json
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-engagement/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Authenticated remote TypeScript client for Native Engagement",
|
|
6
5
|
"engines": {
|
|
7
6
|
"node": ">=24.22.1 <25"
|
|
8
7
|
},
|
|
9
|
-
"license": "
|
|
8
|
+
"license": "Apache-2.0",
|
|
10
9
|
"files": [
|
|
11
10
|
"dist",
|
|
12
|
-
"
|
|
11
|
+
"LICENSE",
|
|
13
12
|
"release.json",
|
|
14
13
|
"THIRD_PARTY_LICENSES.txt"
|
|
15
14
|
],
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/SENLIN746/native-engagement.git"
|
|
19
|
-
},
|
|
20
|
-
"homepage": "https://engagement.shipkitx.com/downloads",
|
|
21
15
|
"publishConfig": {
|
|
22
16
|
"access": "public",
|
|
23
17
|
"tag": "beta"
|
package/release.json
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"sourceCommit": "
|
|
3
|
+
"sourceCommit": "aafc75d7f07fce8c89000738fab3b8a4e3b37158",
|
|
4
4
|
"channel": "beta",
|
|
5
5
|
"bundledComponents": [
|
|
6
|
+
{
|
|
7
|
+
"name": "ajv",
|
|
8
|
+
"version": "8.20.0",
|
|
9
|
+
"license": "MIT"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "fast-deep-equal",
|
|
13
|
+
"version": "3.1.3",
|
|
14
|
+
"license": "MIT"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "json-schema-traverse",
|
|
18
|
+
"version": "1.0.0",
|
|
19
|
+
"license": "MIT"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "fast-uri",
|
|
23
|
+
"version": "3.1.9",
|
|
24
|
+
"license": "BSD-3-Clause"
|
|
25
|
+
},
|
|
6
26
|
{
|
|
7
27
|
"name": "oauth4webapi",
|
|
8
28
|
"version": "3.8.8",
|
|
@@ -14,5 +34,5 @@
|
|
|
14
34
|
"license": "MIT"
|
|
15
35
|
}
|
|
16
36
|
],
|
|
17
|
-
"lockSha256": "
|
|
37
|
+
"lockSha256": "1de45ef4132fe7e835a1edfaff8fcbc7fa1b6d64b1f2c5d3f865245311d0626d"
|
|
18
38
|
}
|
package/README.md
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
# Native Engagement SDK
|
|
2
|
-
|
|
3
|
-
JavaScript and TypeScript access to Native Engagement. Requires Node.js 24.22.1+ in the 24 LTS line.
|
|
4
|
-
|
|
5
|
-
```sh
|
|
6
|
-
npm install @native-engagement/sdk@0.9.0
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
## Account and password sign-in
|
|
10
|
-
|
|
11
|
-
The SDK supports browser-based account sign-in through OAuth Authorization Code with S256 PKCE. Enter your account, password and any MFA challenge on the identity service's browser page. The SDK receives a validated authorization result; your application does not collect the password.
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
import { createNativePublicLogin, openNativeLoginPage,
|
|
15
|
-
RemoteNativeEngagementSdk, prospectClient } from '@native-engagement/sdk';
|
|
16
|
-
|
|
17
|
-
const origin = 'https://engagement.shipkitx.com';
|
|
18
|
-
const login = await createNativePublicLogin(origin);
|
|
19
|
-
const grant = await login.authorize(AbortSignal.timeout(180_000), openNativeLoginPage);
|
|
20
|
-
const sdk = new RemoteNativeEngagementSdk({ baseUrl: origin, accessToken: () => grant.accessToken });
|
|
21
|
-
const prospects = prospectClient(sdk);
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
`openNativeLoginPage` opens the system browser on macOS, Windows and Linux. Applications with their own browser UI can supply an `async authorizationUrl => { ... }` callback instead. The browser callback must reach the Node.js process on its configured loopback address. Use a local Node.js process for this flow; a browser-only application should use the service's web login.
|
|
25
|
-
|
|
26
|
-
Public configuration comes from `/releases/cli-login.json` on the exact HTTPS center, with pinned issuer, public client, resource and business scopes. Your administrator must provision your account and tenant permissions. Current directory and Profile grants govern every operation.
|
|
27
|
-
|
|
28
|
-
Keep the short-lived grant in memory or your protected credential store. Sign in again after expiry; an active identity-service browser session can reuse SSO. The SDK does not automatically persist credentials. Sign out with `await login.revoke(grant)`. For automation, supply a separately authorized access token through a token provider or protected process environment. Password arguments and password-grant login are not offered.
|
|
29
|
-
|
|
30
|
-
## Complete import, creation and association
|
|
31
|
-
|
|
32
|
-
Country, industry, address, contact name/title and original score are optional `profile` strings. Source URLs are optional; supply the actual credential-free HTTP(S) source page when known. Source reference/version, observation time and current/historical status remain explicit. Persist and reuse the complete input and its idempotency key when retrying.
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
const observedAt = new Date().toISOString();
|
|
36
|
-
const input = {
|
|
37
|
-
idempotencyKey: 'research-november-v1', batchRef: 'research-november-v1', datasetRef: 'November research',
|
|
38
|
-
rows: [{
|
|
39
|
-
rowRef: 'row-1', sourceRef: 'reviewed-research-file', sourceVersion: 'v1',
|
|
40
|
-
selection: 'SELECTED', displayName: 'Example Company',
|
|
41
|
-
companyIdentity: { namespace: 'reviewed-company', value: 'company-001' },
|
|
42
|
-
profile: { observedAt, temporalStatus: 'CURRENT', country: 'CN', industry: 'Logistics',
|
|
43
|
-
address: 'Shanghai', contactName: 'Research Contact', contactTitle: 'Director', score: '8/10' },
|
|
44
|
-
contacts: [{ channel: 'EMAIL', value: 'research@example.test', observation: {
|
|
45
|
-
sourceRef: 'reviewed-research-file', sourceVersion: 'v1', observedAt,
|
|
46
|
-
temporalStatus: 'CURRENT', verificationStatus: 'PUBLIC_UNVERIFIED'
|
|
47
|
-
} }]
|
|
48
|
-
}]
|
|
49
|
-
};
|
|
50
|
-
const preview = await prospects.preview(input); // No business write.
|
|
51
|
-
console.log(preview.rows); // Review HELD/REJECTED outcomes before importing.
|
|
52
|
-
await prospects.import(input);
|
|
53
|
-
const batch = await prospects.batch(input.batchRef);
|
|
54
|
-
const imported = batch.rows.find(row => row.status === 'IMPORTED');
|
|
55
|
-
if (!imported?.prospectRef) throw Error('Review the import receipt');
|
|
56
|
-
const company = await prospects.company(imported.prospectRef);
|
|
57
|
-
console.log(company.profileObservations, company.contacts);
|
|
58
|
-
|
|
59
|
-
const route = company.contacts.find(item => item.channel === 'EMAIL');
|
|
60
|
-
const source = route?.observations.find(item => item.temporalStatus === 'CURRENT');
|
|
61
|
-
if (!route || !source) throw Error('A current imported email observation is required');
|
|
62
|
-
const create = {
|
|
63
|
-
idempotencyKey: 'research-november-engagement-001', engagementRef: 'research-november-engagement-001',
|
|
64
|
-
prospectRef: company.prospectRef, contactRouteRef: route.contactRouteRef,
|
|
65
|
-
sourceRef: source.sourceRef, sourceVersion: source.sourceVersion, observedAt: source.observedAt,
|
|
66
|
-
whyFit: 'Reviewed logistics fit', whyNow: 'Reviewed current opportunity'
|
|
67
|
-
};
|
|
68
|
-
await prospects.createEngagement(create);
|
|
69
|
-
const associated = await prospects.engagements(company.prospectRef, { limit: 20 });
|
|
70
|
-
console.log(associated.entries); // Continue with associated.nextCursor when present.
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Creation uses an exact imported CURRENT observation, current authorization and STOP policy. It records why-fit/why-now without sending or scheduling work. Changed source rows require a new version; names, emails and domains are not stable company identifiers. Score strings retain their original scale. Original research and verification belong to the archive/Knowledge owner; Native Engagement owns imported observations, provenance, receipts and engagement facts.
|
|
74
|
-
|
|
75
|
-
## Bounded discovery and task tools
|
|
76
|
-
|
|
77
|
-
`sdk.discoverContracts({query, kind, limit, cursor})` reads contract metadata without whole-library schemas. Use `sdk.schema(name, 'input')` or `'output'` for selected constraints. Existing `contracts()` and `schema(name)` keep their complete response defaults.
|
|
78
|
-
|
|
79
|
-
The remote SDK exports `NativeMcpToolCatalog` and `MCP_CATALOG_META_KEY` for hosts that already own an authenticated MCP client:
|
|
80
|
-
|
|
81
|
-
```js
|
|
82
|
-
import { NativeMcpToolCatalog } from '@native-engagement/sdk';
|
|
83
|
-
|
|
84
|
-
// 每个宿主任务独立管理定义;mcpClient 继续使用原 OAuth 会话。
|
|
85
|
-
const catalog = new NativeMcpToolCatalog(mcpClient);
|
|
86
|
-
await catalog.initialize();
|
|
87
|
-
const tools = await catalog.load({task: 'prospect-import'});
|
|
88
|
-
// 将 tools 注册为本任务的模型工具;它们保留原名称、输入约束和权限元数据。
|
|
89
|
-
await registerTaskTools(tools);
|
|
90
|
-
const result = await catalog.call('prospect.batch.preview', originalBatch);
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Selections may specify `task`, capability `groups`, or exact tool `names`; a new selection replaces the previous set. `catalog.refresh()` preserves the explicit selection on stateless HTTPS. Plain `tools/list` refresh gets the server default. Hosts can use the MCP protocol directly without this helper. The helper caches static definitions, never authorization or business results. Full compatibility remains available through `{mode: 'full'}`.
|
|
94
|
-
|
|
95
|
-
## Logged-in browser SOCIAL clients
|
|
96
|
-
|
|
97
|
-
The development and prepared thin SDK entries export `browserSocialClient`, `browserSearchScope`, `browserAccountClient` and `browserPublicationLifecycle` for Douyin/TikTok browser transport. They require a matching center and an installed, observed platform module. Their presence does not establish platform availability in an existing published package or authorize a channel account.
|
|
98
|
-
|
|
99
|
-
For existing private browser conversations, `browser.autonomy(key, options)` uses the original `social.autonomy.configure` contract. A current Human must provide the exact autonomy/control versions, delegate, expiry and reply limit. Without that bounded delegation, generated text remains a draft. `browserWorkerRoutes` and the existing routed Worker reuse Work/Invocation, account waits and durable original-operation positions; the `browserSocial` selection is retained across restart. Unread media and unmapped messages require Human inspection. Public task/notification Work, publication and media ports preserve their separate approvals and require observed platform configuration. This integration does not implement an Agent Runtime.
|
|
100
|
-
|
|
101
|
-
The development SDK's `browserSocialRuntimeSkill()` returns the packaged Douyin/TikTok guide and its SHA-256 digest for an existing external Runtime/role. The original `xiaohongshuRuntimeSkill()` keeps its API and canonical guide. Both use the same distribution reader; reading instructions grants no tools or action authority. These local guidance readers are not part of the thin remote-client npm entry.
|
|
102
|
-
|
|
103
|
-
```js
|
|
104
|
-
import { browserSocialClient } from '@native-engagement/sdk';
|
|
105
|
-
|
|
106
|
-
// selectedOwner contains the canonical engagementRef, conversationRef and profileRef.
|
|
107
|
-
const browser = browserSocialClient(sdk, { ...selectedOwner, platform: 'TIKTOK' });
|
|
108
|
-
const retained = await browser.get();
|
|
109
|
-
const activity = await browser.activity(); // Retained state only; no browser action.
|
|
110
|
-
// Request freshness only when the retained Source is insufficient for the task.
|
|
111
|
-
const receipt = await browser.read(originalReadKey, {
|
|
112
|
-
view: 'CONTENT', pageLimit: 1, maxItems: 20, maxExpansions: 0, maxScrolls: 0
|
|
113
|
-
});
|
|
114
|
-
const operation = await browser.operation(receipt.entityRefs[0]);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Keep the original read key and dispatch when a response is lost. Poll the original operation and use its returned window; old retained content is not evidence of the latest search. Inbox/notification reads may change the platform's read markers. Backward history supplies context and does not trigger replies to old messages.
|
|
118
|
-
|
|
119
|
-
`search` registers a public query view; `adoptTarget` selects a video or author from an exact Source fact/revision. `adoptDirect` accepts an account-owned inbox thread under current registration policy. Public authors and display names cannot supply private recipients. None of these calls submits content.
|
|
120
|
-
|
|
121
|
-
`draft` freezes the exact Source, complete text and `browserIntent`. `PUBLISH` also freezes video/cover Asset manifests, visibility, declarations and schedule/time zone. Queueing requires the actual current Human review; this client grants no autonomy. Preserve the original request after submission. Use `verify` for an uncertain effect; `authorizeRecovery` requires current Human review after a same-account machine update and permits original verification only. Account pause recovery uses the exact retained activity revision and preserves budgets.
|
|
122
|
-
|
|
123
|
-
`browserPublicationLifecycle(message, operation, retainedView)` projects retained processing/review/schedule observations and the original approved time without browsing or dispatching. `CLIENT_VISIBLE` does not attest public delivery. Rejection, platform cancellation or a settings mismatch requires review of the original business request. `scheduleCancelDraft` and `scheduleRescheduleDraft` create separately reviewed management drafts for an exact current own scheduled POST; they do not alter the original publication request. Local `cancel` only cancels an undispatched QUEUED request. A lost management response continues with its original `verify`, never another submit.
|
|
124
|
-
|
|
125
|
-
## Batch pagination
|
|
126
|
-
|
|
127
|
-
Each response has at most 100 entries; total history has no 100-batch cap. Concurrent imports can shift offset pages; restart from the first page when refreshing. Associated engagements use a separate signed cursor.
|
|
128
|
-
|
|
129
|
-
```js
|
|
130
|
-
let offset = 0;
|
|
131
|
-
for (;;) {
|
|
132
|
-
const page = await prospects.batches({ offset, limit: 20 });
|
|
133
|
-
console.log(page.total, page.entries);
|
|
134
|
-
if (page.nextOffset === null) break;
|
|
135
|
-
offset = page.nextOffset;
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Exports include `RemoteNativeEngagementSdk`, `RemoteNativeEngagementError`, `prospectClient`, `createNativePublicLogin`, `openNativeLoginPage`, `NativePublicLogin`, `NativeLoginConfiguration`, `NativeLoginGrant`, `RemoteSdkOptions` and Prospect DTOs. Generic `contracts`, `schema`, `query` and `command` remain available. Commands require a stable idempotency key. Unknown external effects require original-operation inspection.
|
|
140
|
-
|
|
141
|
-
This beta uses license `UNLICENSED`. [Sign-in and MCP OAuth guide](https://engagement.shipkitx.com/releases/authentication.md) · [Downloads](https://engagement.shipkitx.com/downloads)
|