SharedOS API v0.1.0-alpha.0


SharedOS API / @aicoo/sharedos-client

@aicoo/sharedos-client

Runtime-validated HTTP client for a SharedOS service.

npm install @aicoo/sharedos-client@next
import { SharedOSClient } from "@aicoo/sharedos-client";

const client = new SharedOSClient({ baseUrl: "https://sharedos.example" });
const tools = await client.listTools();
const namespaces = await client.listToolNamespaces();
await client.updateToolNamespaces({ enable: ["calendar"] });

Enabling a namespace changes tool availability only. Each returned or invoked tool still requires its declared capability grant.

SharedOS is currently an 0.x prerelease.

Classes

SharedOSClient

Defined in: packages/client/src/index.ts:61

Constructors

Constructor

new SharedOSClient(options): SharedOSClient

Defined in: packages/client/src/index.ts:67

Parameters
ParameterType
optionsSharedOSClientOptions
Returns

SharedOSClient

Methods

authorize()

authorize(request, options?): Promise<{ allowed: boolean; matchedGrantId?: string; metadata?: JsonObject; reasonCode: string; }>

Defined in: packages/client/src/index.ts:78

Parameters
ParameterType
request{ action: string; resource: { namespace: string; owner?: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; path: string[]; }; }
request.actionstring
request.resource?{ namespace: string; owner?: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; path: string[]; }
request.resource.namespace?string
request.resource.owner?{ kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }
request.resource.path?string[]
options?SharedOSCallOptions
Returns

Promise<{ allowed: boolean; matchedGrantId?: string; metadata?: JsonObject; reasonCode: string; }>

executeTurn()

executeTurn(request, options?): Promise<{ completedAt: string; events: object[]; executionId: string; metadata?: JsonObject; output: JsonValue; startedAt: string; status: "succeeded"; traceId: string; version: "1"; } | { completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; events: object[]; executionId: string; metadata?: JsonObject; startedAt: string; status: "denied"; traceId: string; version: "1"; } | { completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; events: object[]; executionId: string; metadata?: JsonObject; startedAt: string; status: "failed"; traceId: string; version: "1"; } | { completedAt: string; error?: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; events: object[]; executionId: string; metadata?: JsonObject; startedAt: string; status: "cancelled"; traceId: string; version: "1"; }>

Defined in: packages/client/src/index.ts:134

Parameters
ParameterType
request{ agent: { agentId: string; kind: "agent"; }; executionId: string; message: { createdAt: string; id: string; intent: string; payload: JsonValue; provenance?: { metadata?: JsonObject; parentIds: string[]; source: string; }; purpose: string; receiver: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; replyTo?: string; sender: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; traceId: string; version: "1"; }; metadata?: JsonObject; options?: { maxSteps?: number; maxToolCalls?: number; timeoutMs?: number; }; state?: JsonObject; version: "1"; }
request.agent{ agentId: string; kind: "agent"; }
request.agent.agentId?string
request.agent.kind?"agent"
request.executionId?string
request.message?{ createdAt: string; id: string; intent: string; payload: JsonValue; provenance?: { metadata?: JsonObject; parentIds: string[]; source: string; }; purpose: string; receiver: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; replyTo?: string; sender: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; traceId: string; version: "1"; }
request.message.createdAt?string
request.message.id?string
request.message.intent?string
request.message.payload?JsonValue
request.message.provenance?{ metadata?: JsonObject; parentIds: string[]; source: string; }
request.message.provenance.metadata?JsonObject
request.message.provenance.parentIds?string[]
request.message.provenance.source?string
request.message.purpose?string
request.message.receiver?{ kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }
request.message.replyTo?string
request.message.sender?{ kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }
request.message.traceId?string
request.message.version?"1"
request.metadata?JsonObject
request.options?{ maxSteps?: number; maxToolCalls?: number; timeoutMs?: number; }
request.options.maxSteps?number
request.options.maxToolCalls?number
request.options.timeoutMs?number
request.state?JsonObject
request.version?"1"
options?SharedOSCallOptions
Returns

Promise<{ completedAt: string; events: object[]; executionId: string; metadata?: JsonObject; output: JsonValue; startedAt: string; status: "succeeded"; traceId: string; version: "1"; } | { completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; events: object[]; executionId: string; metadata?: JsonObject; startedAt: string; status: "denied"; traceId: string; version: "1"; } | { completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; events: object[]; executionId: string; metadata?: JsonObject; startedAt: string; status: "failed"; traceId: string; version: "1"; } | { completedAt: string; error?: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; events: object[]; executionId: string; metadata?: JsonObject; startedAt: string; status: "cancelled"; traceId: string; version: "1"; }>

health()

health(options?): Promise<{ protocolVersion: "1"; status: "ok"; }>

Defined in: packages/client/src/index.ts:74

Parameters
ParameterType
options?SharedOSCallOptions
Returns

Promise<{ protocolVersion: "1"; status: "ok"; }>

invokeResource()

invokeResource(operation, options?): Promise<{ completedAt: string; metadata?: JsonObject; operationId: string; output: JsonValue; status: "succeeded"; } | { completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; metadata?: JsonObject; operationId: string; status: "denied"; } | { completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; metadata?: JsonObject; operationId: string; status: "failed"; }>

Defined in: packages/client/src/index.ts:115

Parameters
ParameterType
operation{ action: string; input?: JsonValue; metadata?: JsonObject; operationId: string; resource: { namespace: string; owner?: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; path: string[]; }; }
operation.actionstring
operation.input?JsonValue
operation.metadata?JsonObject
operation.operationId?string
operation.resource?{ namespace: string; owner?: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; path: string[]; }
operation.resource.namespace?string
operation.resource.owner?{ kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }
operation.resource.path?string[]
options?SharedOSCallOptions
Returns

Promise<{ completedAt: string; metadata?: JsonObject; operationId: string; output: JsonValue; status: "succeeded"; } | { completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; metadata?: JsonObject; operationId: string; status: "denied"; } | { completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; metadata?: JsonObject; operationId: string; status: "failed"; }>

invokeTool()

invokeTool(call, options?): Promise<{ callId: string; completedAt: string; metadata?: JsonObject; output: JsonValue; status: "succeeded"; tool: string; } | { callId: string; completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; metadata?: JsonObject; status: "denied"; tool: string; } | { callId: string; completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; metadata?: JsonObject; status: "failed"; tool: string; }>

Defined in: packages/client/src/index.ts:111

Parameters
ParameterType
call{ arguments: JsonObject; id: string; requestedAt: string; tool: string; traceId: string; }
call.argumentsJsonObject
call.id?string
call.requestedAt?string
call.tool?string
call.traceId?string
options?SharedOSCallOptions
Returns

Promise<{ callId: string; completedAt: string; metadata?: JsonObject; output: JsonValue; status: "succeeded"; tool: string; } | { callId: string; completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; metadata?: JsonObject; status: "denied"; tool: string; } | { callId: string; completedAt: string; error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; metadata?: JsonObject; status: "failed"; tool: string; }>

listToolNamespaces()

listToolNamespaces(options?): Promise<{ namespaces: object[]; summary: { disabled: number; enabled: number; total: number; }; }>

Defined in: packages/client/src/index.ts:89

Parameters
ParameterType
options?SharedOSCallOptions
Returns

Promise<{ namespaces: object[]; summary: { disabled: number; enabled: number; total: number; }; }>

listTools()

listTools(options?): Promise<readonly object[]>

Defined in: packages/client/src/index.ts:85

Parameters
ParameterType
options?SharedOSCallOptions
Returns

Promise<readonly object[]>

sendMessage()

sendMessage(envelope, options?): Promise<{ messageId: string; metadata?: JsonObject; status: "accepted"; timestamp: string; } | { messageId: string; metadata?: JsonObject; status: "delivered"; timestamp: string; } | { error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; messageId: string; metadata?: JsonObject; status: "denied"; timestamp: string; } | { error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; messageId: string; metadata?: JsonObject; status: "failed"; timestamp: string; }>

Defined in: packages/client/src/index.ts:127

Parameters
ParameterType
envelope{ createdAt: string; id: string; intent: string; payload: JsonValue; provenance?: { metadata?: JsonObject; parentIds: string[]; source: string; }; purpose: string; receiver: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; replyTo?: string; sender: { kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }; traceId: string; version: "1"; }
envelope.createdAtstring
envelope.id?string
envelope.intent?string
envelope.payload?JsonValue
envelope.provenance?{ metadata?: JsonObject; parentIds: string[]; source: string; }
envelope.provenance.metadata?JsonObject
envelope.provenance.parentIds?string[]
envelope.provenance.source?string
envelope.purpose?string
envelope.receiver?{ kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }
envelope.replyTo?string
envelope.sender?{ kind: "human"; userId: string; } | { agentId: string; kind: "agent"; } | { conversationId: string; kind: "group"; } | { kind: "service"; serviceId: string; }
envelope.traceId?string
envelope.version?"1"
options?SharedOSCallOptions
Returns

Promise<{ messageId: string; metadata?: JsonObject; status: "accepted"; timestamp: string; } | { messageId: string; metadata?: JsonObject; status: "delivered"; timestamp: string; } | { error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; messageId: string; metadata?: JsonObject; status: "denied"; timestamp: string; } | { error: { code: string; details?: JsonObject; message: string; retryable?: boolean; }; messageId: string; metadata?: JsonObject; status: "failed"; timestamp: string; }>

updateToolNamespaces()

updateToolNamespaces(update, options?): Promise<{ namespaces: object[]; summary: { disabled: number; enabled: number; total: number; }; }>

Defined in: packages/client/src/index.ts:98

Parameters
ParameterType
update{ disable?: string[]; enable?: string[]; }
update.disable?string[]
update.enable?string[]
options?SharedOSCallOptions
Returns

Promise<{ namespaces: object[]; summary: { disabled: number; enabled: number; total: number; }; }>


SharedOSClientError

Defined in: packages/client/src/index.ts:47

Extends

  • Error

Constructors

Constructor

new SharedOSClientError(args): SharedOSClientError

Defined in: packages/client/src/index.ts:52

Parameters
ParameterType
args{ code: string; message: string; requestId?: string; status: number; }
args.codestring
args.messagestring
args.requestId?string
args.statusnumber
Returns

SharedOSClientError

Overrides

Error.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
<a id="property-cause"></a> cause?publicunknown-Error.causenode_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26
<a id="property-code"></a> codereadonlystring--packages/client/src/index.ts:49
<a id="property-message"></a> messagepublicstring-Error.messagenode_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077
<a id="property-name"></a> namepublicstring-Error.namenode_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076
<a id="property-requestid"></a> requestIdreadonlystring | undefined--packages/client/src/index.ts:50
<a id="property-stack"></a> stack?publicstring-Error.stacknode_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078
<a id="property-status"></a> statusreadonlynumber--packages/client/src/index.ts:48
<a id="property-stacktracelimit"></a> stackTraceLimitstaticnumberThe Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames.Error.stackTraceLimitnode_modules/.pnpm/@types+node@22.20.1/node_modules/@types/node/globals.d.ts:68

Methods

captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: node_modules/.pnpm/@types+node@22.20.1/node_modules/@types/node/globals.d.ts:52

Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.

const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`

The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.

The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.

The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:

function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
Parameters
ParameterType
targetObjectobject
constructorOpt?Function
Returns

void

Inherited from

Error.captureStackTrace

prepareStackTrace()

static prepareStackTrace(err, stackTraces): any

Defined in: node_modules/.pnpm/@types+node@22.20.1/node_modules/@types/node/globals.d.ts:56

Parameters
ParameterType
errError
stackTracesCallSite[]
Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from

Error.prepareStackTrace

Interfaces

SharedOSCallOptions

Defined in: packages/client/src/index.ts:39

Properties

PropertyTypeDefined in
<a id="property-headers"></a> headers?HeadersInitpackages/client/src/index.ts:42
<a id="property-purpose"></a> purpose?stringpackages/client/src/index.ts:40
<a id="property-signal"></a> signal?AbortSignalpackages/client/src/index.ts:41

SharedOSClientOptions

Defined in: packages/client/src/index.ts:32

Properties

PropertyTypeDefined in
<a id="property-baseurl"></a> baseUrlstringpackages/client/src/index.ts:33
<a id="property-fetch"></a> fetch?{(input, init?): Promise<Response>; (input, init?): Promise<Response>; }packages/client/src/index.ts:35
<a id="property-headers-1"></a> headers?HeadersInit | (() => HeadersInit | Promise<HeadersInit>)packages/client/src/index.ts:36
<a id="property-token"></a> token?string | (() => string | Promise<string>)packages/client/src/index.ts:34

Type Aliases

RemoteExecutionRequest

RemoteExecutionRequest = z.infer<typeof RemoteExecutionRequestSchema>>

Defined in: packages/contracts/dist/http.d.ts:2075


RemoteResourceOperation

RemoteResourceOperation = z.infer<typeof RemoteResourceOperationSchema>>

Defined in: packages/contracts/dist/http.d.ts:805


SharedOSHealth

SharedOSHealth = z.infer<typeof SharedOSHealthSchema>>

Defined in: packages/contracts/dist/http.d.ts:2086