refactor: update examples to use npm package imports

Replace relative path imports (../src/agent.js, ../src/sdk.js) with
@shipany/open-agent-sdk package imports across all 10 examples.
Bump version to 0.1.1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
idoubiandClaude Opus 4.6 committed 2026-03-31 22:35:53 +08:00
1 parent 308ee326a3
commit a86ab32b07
12 files changed
+41 -19

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
* *
* Run: npx tsx examples/01-simple-query.ts * Run: npx tsx examples/01-simple-query.ts
*/ */
import { createAgent } from '../src/agent.js' import { createAgent } from '@shipany/open-agent-sdk'
async function main() { async function main() {
console.log('--- Example 1: Simple Query ---\n') console.log('--- Example 1: Simple Query ---\n')
+1 -1
View File
@@ -6,7 +6,7 @@
* *
* Run: npx tsx examples/02-multi-tool.ts * Run: npx tsx examples/02-multi-tool.ts
*/ */
import { createAgent } from '../src/agent.js' import { createAgent } from '@shipany/open-agent-sdk'
async function main() { async function main() {
console.log('--- Example 2: Multi-Tool Orchestration ---\n') console.log('--- Example 2: Multi-Tool Orchestration ---\n')
+1 -1
View File
@@ -6,7 +6,7 @@
* *
* Run: npx tsx examples/03-multi-turn.ts * Run: npx tsx examples/03-multi-turn.ts
*/ */
import { createAgent } from '../src/agent.js' import { createAgent } from '@shipany/open-agent-sdk'
async function main() { async function main() {
console.log('--- Example 3: Multi-Turn Conversation ---\n') console.log('--- Example 3: Multi-Turn Conversation ---\n')
+1 -1
View File
@@ -6,7 +6,7 @@
* *
* Run: npx tsx examples/04-prompt-api.ts * Run: npx tsx examples/04-prompt-api.ts
*/ */
import { createAgent } from '../src/agent.js' import { createAgent } from '@shipany/open-agent-sdk'
async function main() { async function main() {
console.log('--- Example 4: Simple Prompt API ---\n') console.log('--- Example 4: Simple Prompt API ---\n')
+1 -1
View File
@@ -5,7 +5,7 @@
* *
* Run: npx tsx examples/05-custom-system-prompt.ts * Run: npx tsx examples/05-custom-system-prompt.ts
*/ */
import { createAgent } from '../src/agent.js' import { createAgent } from '@shipany/open-agent-sdk'
async function main() { async function main() {
console.log('--- Example 5: Custom System Prompt ---\n') console.log('--- Example 5: Custom System Prompt ---\n')
+1 -1
View File
@@ -10,7 +10,7 @@
* *
* Run: npx tsx examples/06-mcp-server.ts * Run: npx tsx examples/06-mcp-server.ts
*/ */
import { createAgent } from '../src/agent.js' import { createAgent } from '@shipany/open-agent-sdk'
async function main() { async function main() {
console.log('--- Example 6: MCP Server Integration ---\n') console.log('--- Example 6: MCP Server Integration ---\n')
+1 -2
View File
@@ -5,8 +5,7 @@
* *
* Run: npx tsx examples/07-custom-tools.ts * Run: npx tsx examples/07-custom-tools.ts
*/ */
import '../src/setup-globals.js' import { createAgent, getAllBaseTools } from '@shipany/open-agent-sdk'
import { createAgent, getAllBaseTools } from '../src/sdk.js'
/** /**
* Helper to create custom tools compatible with the engine. * Helper to create custom tools compatible with the engine.
+1 -1
View File
@@ -6,7 +6,7 @@
* *
* Run: npx tsx examples/08-official-api-compat.ts * Run: npx tsx examples/08-official-api-compat.ts
*/ */
import { query } from '../src/sdk.js' import { query } from '@shipany/open-agent-sdk'
async function main() { async function main() {
console.log('--- Example 8: Official SDK-Compatible API ---\n') console.log('--- Example 8: Official SDK-Compatible API ---\n')
+1 -1
View File
@@ -6,7 +6,7 @@
* *
* Run: npx tsx examples/09-subagents.ts * Run: npx tsx examples/09-subagents.ts
*/ */
import { query } from '../src/sdk.js' import { query } from '@shipany/open-agent-sdk'
async function main() { async function main() {
console.log('--- Example 9: Subagents ---\n') console.log('--- Example 9: Subagents ---\n')
+1 -1
View File
@@ -6,7 +6,7 @@
* *
* Run: npx tsx examples/10-permissions.ts * Run: npx tsx examples/10-permissions.ts
*/ */
import { query } from '../src/sdk.js' import { query } from '@shipany/open-agent-sdk'
async function main() { async function main() {
console.log('--- Example 10: Read-Only Agent ---\n') console.log('--- Example 10: Read-Only Agent ---\n')
+26 -6
View File
@@ -1,16 +1,17 @@
{ {
"name": "@shipany/open-agent-sdk", "name": "@shipany/open-agent-sdk",
"version": "0.1.0", "version": "0.1.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@shipany/open-agent-sdk", "name": "@shipany/open-agent-sdk",
"version": "0.1.0", "version": "0.1.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alcalzone/jsonl-db": "^4.0.2", "@alcalzone/jsonl-db": "^4.0.2",
"@anthropic-ai/sdk": "^0.52.0", "@anthropic-ai/sdk": "^0.52.0",
"@commander-js/extra-typings": "^12.1.0",
"@growthbook/growthbook": "^1.6.5", "@growthbook/growthbook": "^1.6.5",
"@modelcontextprotocol/sdk": "^1.12.1", "@modelcontextprotocol/sdk": "^1.12.1",
"@opentelemetry/api": "^1.9.1", "@opentelemetry/api": "^1.9.1",
@@ -30,6 +31,7 @@
"chokidar": "^4.0.0", "chokidar": "^4.0.0",
"cli-highlight": "^2.1.11", "cli-highlight": "^2.1.11",
"code-excerpt": "^4.0.0", "code-excerpt": "^4.0.0",
"commander": "^12.1.0",
"diff": "^7.0.0", "diff": "^7.0.0",
"emoji-regex": "^10.4.0", "emoji-regex": "^10.4.0",
"env-paths": "^3.0.0", "env-paths": "^3.0.0",
@@ -138,6 +140,15 @@
"anthropic-ai-sdk": "bin/cli" "anthropic-ai-sdk": "bin/cli"
} }
}, },
"node_modules/@commander-js/extra-typings": {
"version": "12.1.0",
"resolved": "https://registry.npmjs.org/@commander-js/extra-typings/-/extra-typings-12.1.0.tgz",
"integrity": "sha512-wf/lwQvWAA0goIghcb91dQYpkLBcyhOhQNqG/VgWhnKzgt+UOMvra7EX/2fv70arm5RW+PUHoQHHDa6/p77Eqg==",
"license": "MIT",
"peerDependencies": {
"commander": "~12.1.0"
}
},
"node_modules/@esbuild/aix-ppc64": { "node_modules/@esbuild/aix-ppc64": {
"version": "0.27.4", "version": "0.27.4",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz",
@@ -1936,10 +1947,13 @@
} }
}, },
"node_modules/commander": { "node_modules/commander": {
"version": "2.20.3", "version": "12.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
"license": "MIT" "license": "MIT",
"engines": {
"node": ">=18"
}
}, },
"node_modules/content-disposition": { "node_modules/content-disposition": {
"version": "1.0.1", "version": "1.0.1",
@@ -4786,6 +4800,12 @@
"node": ">= 0.10.0" "node": ">= 0.10.0"
} }
}, },
"node_modules/xss/node_modules/commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"license": "MIT"
},
"node_modules/y18n": { "node_modules/y18n": {
"version": "5.0.8", "version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
+5 -2
View File
@@ -12,7 +12,7 @@
"bugs": { "bugs": {
"url": "https://github.com/shipany-ai/open-agent-sdk/issues" "url": "https://github.com/shipany-ai/open-agent-sdk/issues"
}, },
"version": "0.1.0", "version": "0.1.1",
"description": "Open-source Agent SDK inspired by @anthropic-ai/claude-agent-sdk. Runs the agent loop in-process — no local CLI required. Deploy anywhere: cloud, serverless, Docker, CI/CD.", "description": "Open-source Agent SDK inspired by @anthropic-ai/claude-agent-sdk. Runs the agent loop in-process — no local CLI required. Deploy anywhere: cloud, serverless, Docker, CI/CD.",
"type": "module", "type": "module",
"main": "./dist/sdk.js", "main": "./dist/sdk.js",
@@ -25,7 +25,8 @@
"./types": { "./types": {
"types": "./dist/entrypoints/agentSdkTypes.d.ts", "types": "./dist/entrypoints/agentSdkTypes.d.ts",
"import": "./dist/entrypoints/agentSdkTypes.js" "import": "./dist/entrypoints/agentSdkTypes.js"
} },
"./dist/*": "./dist/*"
}, },
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
@@ -40,6 +41,7 @@
"dependencies": { "dependencies": {
"@alcalzone/jsonl-db": "^4.0.2", "@alcalzone/jsonl-db": "^4.0.2",
"@anthropic-ai/sdk": "^0.52.0", "@anthropic-ai/sdk": "^0.52.0",
"@commander-js/extra-typings": "^12.1.0",
"@growthbook/growthbook": "^1.6.5", "@growthbook/growthbook": "^1.6.5",
"@modelcontextprotocol/sdk": "^1.12.1", "@modelcontextprotocol/sdk": "^1.12.1",
"@opentelemetry/api": "^1.9.1", "@opentelemetry/api": "^1.9.1",
@@ -59,6 +61,7 @@
"chokidar": "^4.0.0", "chokidar": "^4.0.0",
"cli-highlight": "^2.1.11", "cli-highlight": "^2.1.11",
"code-excerpt": "^4.0.0", "code-excerpt": "^4.0.0",
"commander": "^12.1.0",
"diff": "^7.0.0", "diff": "^7.0.0",
"emoji-regex": "^10.4.0", "emoji-regex": "^10.4.0",
"env-paths": "^3.0.0", "env-paths": "^3.0.0",