@oxap/sdk 0.0.0-stage → 0.1.0-alpha.33

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,22 @@
1
+ export type TimeoutDiagnosticContext = {
2
+ operation: string;
3
+ timeout_ms: number;
4
+ stream_id?: string;
5
+ message_id?: string;
6
+ session_id?: string;
7
+ provider_id?: string;
8
+ api?: string;
9
+ model_ref?: string;
10
+ model_id?: string;
11
+ };
12
+ export type TimeoutDiagnostics = TimeoutDiagnosticContext & {
13
+ suggestions: string[];
14
+ };
15
+ export type ErrorWithDiagnostics = Error & {
16
+ diagnostics?: TimeoutDiagnostics;
17
+ };
18
+ export declare const TIMEOUT_SUGGESTIONS: readonly ["Verify the oapx binary is installed, executable, and still running.", "Check network connectivity and provider service health.", "Review server logs using the included stream_id/message_id for correlation.", "Increase the responseTimeoutMs/frameTimeoutMs option if the provider is expected to be slow."];
19
+ export declare function createTimeoutDiagnostics(context: TimeoutDiagnosticContext): TimeoutDiagnostics;
20
+ export declare function formatTimeoutMessage(context: TimeoutDiagnosticContext): string;
21
+ export declare function timeoutError(message: string, context: TimeoutDiagnosticContext): ErrorWithDiagnostics;
22
+ export declare function isTimeoutLikeError(error: unknown): boolean;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TIMEOUT_SUGGESTIONS = void 0;
4
+ exports.createTimeoutDiagnostics = createTimeoutDiagnostics;
5
+ exports.formatTimeoutMessage = formatTimeoutMessage;
6
+ exports.timeoutError = timeoutError;
7
+ exports.isTimeoutLikeError = isTimeoutLikeError;
8
+ exports.TIMEOUT_SUGGESTIONS = [
9
+ "Verify the oapx binary is installed, executable, and still running.",
10
+ "Check network connectivity and provider service health.",
11
+ "Review server logs using the included stream_id/message_id for correlation.",
12
+ "Increase the responseTimeoutMs/frameTimeoutMs option if the provider is expected to be slow.",
13
+ ];
14
+ function createTimeoutDiagnostics(context) {
15
+ return {
16
+ ...context,
17
+ suggestions: [...exports.TIMEOUT_SUGGESTIONS],
18
+ };
19
+ }
20
+ function formatTimeoutMessage(context) {
21
+ const diagnostics = createTimeoutDiagnostics(context);
22
+ const ids = formatIds(diagnostics);
23
+ const provider = diagnostics.provider_id ? ` for provider '${diagnostics.provider_id}'` : "";
24
+ const model = diagnostics.model_ref ? ` (model_ref='${diagnostics.model_ref}')` : "";
25
+ return `Timed out waiting for ${diagnostics.operation} after ${diagnostics.timeout_ms}ms${provider}${model}${ids}. Suggestions: ${diagnostics.suggestions.join(" ")}`;
26
+ }
27
+ function timeoutError(message, context) {
28
+ const error = new Error(message);
29
+ error.diagnostics = createTimeoutDiagnostics(context);
30
+ return error;
31
+ }
32
+ function isTimeoutLikeError(error) {
33
+ return error instanceof Error && /^timed out waiting for|^Timed out waiting for|timed out after/.test(error.message);
34
+ }
35
+ function formatIds(diagnostics) {
36
+ const fields = [];
37
+ if (diagnostics.stream_id)
38
+ fields.push(`stream_id=${diagnostics.stream_id}`);
39
+ if (diagnostics.session_id)
40
+ fields.push(`session_id=${diagnostics.session_id}`);
41
+ if (diagnostics.message_id)
42
+ fields.push(`message_id=${diagnostics.message_id}`);
43
+ return fields.length > 0 ? ` (${fields.join(", ")})` : "";
44
+ }
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@oxap/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.33",
4
+ "description": "TypeScript SDK for the Open Agent Protocol project's runtime, over its stdio protocol",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
+ "scripts": {
8
+ "build:sdk": "tsc -p tsconfig.json",
9
+ "check:declarations": "node scripts/check-npm-declarations.mjs",
10
+ "check:readme": "node scripts/check-readme-samples.mjs",
11
+ "test:sdk": "npm run build:sdk && node --test dist/test/**/*.test.js",
12
+ "demo:start": "npm run build:sdk && node dist/demo/server.js",
13
+ "test": "npm run test:sdk && npm run check:readme"
14
+ },
15
+ "keywords": [
16
+ "oap",
17
+ "open-agent-protocol",
18
+ "sdk",
19
+ "typescript",
20
+ "stdio"
21
+ ],
22
+ "author": "Open Agent Protocol contributors",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/lsm/oxap.git"
26
+ },
27
+ "homepage": "https://github.com/lsm/oxap/tree/main/sdk/typescript",
28
+ "license": "ISC",
29
+ "type": "commonjs",
30
+ "files": [
31
+ "dist/src/",
32
+ "README.md"
33
+ ],
34
+ "devDependencies": {
35
+ "@types/node": "^24.0.0",
36
+ "typescript": "^5.8.3"
37
+ },
38
+ "dependencies": {
39
+ "lossless-json": "4.3.2",
40
+ "nanoid": "^5.1.5",
41
+ "ulid": "^3.0.2"
42
+ },
43
+ "optionalDependencies": {
44
+ "@oxap/cli": "0.1.0-alpha.33"
45
+ }
6
46
  }