@oxy.so/mention-sdk 0.0.0-stage → 0.1.2

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.
@@ -0,0 +1,27 @@
1
+ import { MentionPublishInput } from '@oxy.so/mention-contracts';
2
+ export declare class MentionPublishingError extends Error {
3
+ readonly status: number;
4
+ readonly unknownOutcome: boolean;
5
+ constructor(status: number, unknownOutcome: boolean);
6
+ }
7
+ /** A resource-scoped Oxy MCP OAuth token, never an ordinary Oxy human session. */
8
+ export declare class MentionPublishingClient {
9
+ private readonly options;
10
+ constructor(options: {
11
+ accessToken: string;
12
+ apiOrigin?: string;
13
+ publicOrigin?: string;
14
+ fetch?: typeof fetch;
15
+ });
16
+ private request;
17
+ identity(): Promise<{
18
+ oxyUserId: string;
19
+ handle: string;
20
+ displayName: string;
21
+ }>;
22
+ /** The key is persisted by the caller before dispatch; Mention reserves it durably. */
23
+ publish(input: MentionPublishInput, effectKey: string): Promise<{
24
+ id: string;
25
+ url: string;
26
+ }>;
27
+ }
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MentionPublishingClient = exports.MentionPublishingError = void 0;
4
+ const mention_contracts_1 = require("@oxy.so/mention-contracts");
5
+ class MentionPublishingError extends Error {
6
+ status;
7
+ unknownOutcome;
8
+ constructor(status, unknownOutcome) {
9
+ super(unknownOutcome
10
+ ? 'Mention delivery outcome is unknown; do not issue a new effect key'
11
+ : 'Mention refused the request');
12
+ this.status = status;
13
+ this.unknownOutcome = unknownOutcome;
14
+ }
15
+ }
16
+ exports.MentionPublishingError = MentionPublishingError;
17
+ /** A resource-scoped Oxy MCP OAuth token, never an ordinary Oxy human session. */
18
+ class MentionPublishingClient {
19
+ options;
20
+ constructor(options) {
21
+ this.options = options;
22
+ }
23
+ async request(path, init) {
24
+ const origin = this.options.apiOrigin ?? 'https://api.mention.earth';
25
+ const response = await (this.options.fetch ?? fetch)(new URL(path, origin), {
26
+ ...init,
27
+ redirect: 'error',
28
+ signal: AbortSignal.timeout(20000),
29
+ headers: { Authorization: `Bearer ${this.options.accessToken}`, ...init?.headers },
30
+ });
31
+ if (!response.ok)
32
+ throw new MentionPublishingError(response.status, init?.method === 'POST' && (response.status >= 500 || response.status === 409));
33
+ return response.json();
34
+ }
35
+ async identity() {
36
+ return mention_contracts_1.MentionIdentity.parse(await this.request('/mcp/bundles/me'));
37
+ }
38
+ /** The key is persisted by the caller before dispatch; Mention reserves it durably. */
39
+ async publish(input, effectKey) {
40
+ if (!/^mcp:[a-f0-9]{64}$/.test(effectKey))
41
+ throw new Error('Invalid Mention effect key');
42
+ const body = mention_contracts_1.MentionPublishInput.parse(input);
43
+ const result = mention_contracts_1.MentionPublishResponse.parse(await this.request('/posts', {
44
+ method: 'POST',
45
+ headers: {
46
+ 'Content-Type': 'application/json',
47
+ 'Idempotency-Key': effectKey,
48
+ 'X-Oxy-MCP-Tool': 'create-post',
49
+ },
50
+ body: JSON.stringify(body),
51
+ }));
52
+ return {
53
+ id: result.post.id,
54
+ url: new URL(`/p/${encodeURIComponent(result.post.id)}`, this.options.publicOrigin ?? 'https://mention.earth').href,
55
+ };
56
+ }
57
+ }
58
+ exports.MentionPublishingClient = MentionPublishingClient;
package/package.json CHANGED
@@ -1,6 +1,23 @@
1
1
  {
2
2
  "name": "@oxy.so/mention-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.2",
4
+ "type": "commonjs",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.json",
18
+ "test": "bun test src"
19
+ },
20
+ "dependencies": {
21
+ "@oxy.so/mention-contracts": "0.1.2"
22
+ }
23
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.