@tarkahq/sdk 0.0.0-stage → 0.3.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.
Files changed (130) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +69 -0
  3. package/README.md +700 -2
  4. package/api-source.json +38 -0
  5. package/dist/cjs/client.d.ts +114 -0
  6. package/dist/cjs/client.js +174 -0
  7. package/dist/cjs/errors.d.ts +27 -0
  8. package/dist/cjs/errors.js +78 -0
  9. package/dist/cjs/generated/google/api/annotations.d.ts +1 -0
  10. package/dist/cjs/generated/google/api/annotations.js +10 -0
  11. package/dist/cjs/generated/google/api/http.d.ts +395 -0
  12. package/dist/cjs/generated/google/api/http.js +421 -0
  13. package/dist/cjs/generated/google/protobuf/descriptor.d.ts +873 -0
  14. package/dist/cjs/generated/google/protobuf/descriptor.js +3992 -0
  15. package/dist/cjs/generated/google/protobuf/empty.d.ts +35 -0
  16. package/dist/cjs/generated/google/protobuf/empty.js +58 -0
  17. package/dist/cjs/generated/google/protobuf/struct.d.ts +127 -0
  18. package/dist/cjs/generated/google/protobuf/struct.js +529 -0
  19. package/dist/cjs/generated/google/protobuf/timestamp.d.ts +128 -0
  20. package/dist/cjs/generated/google/protobuf/timestamp.js +95 -0
  21. package/dist/cjs/generated/protoc-gen-openapiv2/options/annotations.d.ts +1 -0
  22. package/dist/cjs/generated/protoc-gen-openapiv2/options/annotations.js +10 -0
  23. package/dist/cjs/generated/protoc-gen-openapiv2/options/openapiv2.d.ts +983 -0
  24. package/dist/cjs/generated/protoc-gen-openapiv2/options/openapiv2.js +4874 -0
  25. package/dist/cjs/generated/tarka/access/v1/access.d.ts +322 -0
  26. package/dist/cjs/generated/tarka/access/v1/access.js +2979 -0
  27. package/dist/cjs/generated/tarka/channels/v1/channels.d.ts +370 -0
  28. package/dist/cjs/generated/tarka/channels/v1/channels.js +3603 -0
  29. package/dist/cjs/generated/tarka/gateway/v1/gateway.d.ts +804 -0
  30. package/dist/cjs/generated/tarka/gateway/v1/gateway.js +8081 -0
  31. package/dist/cjs/generated/tarka/iam/v1/iam.d.ts +1291 -0
  32. package/dist/cjs/generated/tarka/iam/v1/iam.js +13207 -0
  33. package/dist/cjs/generated/tarka/inference/v1/inference.d.ts +699 -0
  34. package/dist/cjs/generated/tarka/inference/v1/inference.js +7058 -0
  35. package/dist/cjs/generated/tarka/provisioning/v1/agent_secrets.d.ts +70 -0
  36. package/dist/cjs/generated/tarka/provisioning/v1/agent_secrets.js +603 -0
  37. package/dist/cjs/generated/tarka/provisioning/v1/billing_quote.d.ts +171 -0
  38. package/dist/cjs/generated/tarka/provisioning/v1/billing_quote.js +1588 -0
  39. package/dist/cjs/generated/tarka/provisioning/v1/job.d.ts +168 -0
  40. package/dist/cjs/generated/tarka/provisioning/v1/job.js +1505 -0
  41. package/dist/cjs/generated/tarka/provisioning/v1/provisioning.d.ts +2644 -0
  42. package/dist/cjs/generated/tarka/provisioning/v1/provisioning.js +19501 -0
  43. package/dist/cjs/generated/tarka/provisioning/v1/registry_credentials.d.ts +89 -0
  44. package/dist/cjs/generated/tarka/provisioning/v1/registry_credentials.js +856 -0
  45. package/dist/cjs/generated/tarka/provisioning/v1/sandbox.d.ts +431 -0
  46. package/dist/cjs/generated/tarka/provisioning/v1/sandbox.js +3203 -0
  47. package/dist/cjs/generated/tarka/provisioning/v1/source_builds.d.ts +291 -0
  48. package/dist/cjs/generated/tarka/provisioning/v1/source_builds.js +3920 -0
  49. package/dist/cjs/grpc.d.ts +12 -0
  50. package/dist/cjs/grpc.js +55 -0
  51. package/dist/cjs/index.d.ts +6 -0
  52. package/dist/cjs/index.js +21 -0
  53. package/dist/cjs/package.json +1 -0
  54. package/dist/cjs/resources/inference.d.ts +293 -0
  55. package/dist/cjs/resources/inference.js +451 -0
  56. package/dist/cjs/resources/provisioning.d.ts +389 -0
  57. package/dist/cjs/resources/provisioning.js +552 -0
  58. package/dist/cjs/resources/sandboxes.d.ts +360 -0
  59. package/dist/cjs/resources/sandboxes.js +732 -0
  60. package/dist/cjs/rpc-types.d.ts +36 -0
  61. package/dist/cjs/rpc-types.js +29 -0
  62. package/dist/cjs/runtime.d.ts +99 -0
  63. package/dist/cjs/runtime.js +473 -0
  64. package/dist/cjs/transport.d.ts +60 -0
  65. package/dist/cjs/transport.js +114 -0
  66. package/dist/cjs/types.d.ts +309 -0
  67. package/dist/cjs/types.js +2 -0
  68. package/dist/esm/client.d.ts +114 -0
  69. package/dist/esm/client.js +169 -0
  70. package/dist/esm/errors.d.ts +27 -0
  71. package/dist/esm/errors.js +71 -0
  72. package/dist/esm/generated/google/api/annotations.d.ts +1 -0
  73. package/dist/esm/generated/google/api/annotations.js +7 -0
  74. package/dist/esm/generated/google/api/http.d.ts +395 -0
  75. package/dist/esm/generated/google/api/http.js +418 -0
  76. package/dist/esm/generated/google/protobuf/descriptor.d.ts +873 -0
  77. package/dist/esm/generated/google/protobuf/descriptor.js +3977 -0
  78. package/dist/esm/generated/google/protobuf/empty.d.ts +35 -0
  79. package/dist/esm/generated/google/protobuf/empty.js +55 -0
  80. package/dist/esm/generated/google/protobuf/struct.d.ts +127 -0
  81. package/dist/esm/generated/google/protobuf/struct.js +524 -0
  82. package/dist/esm/generated/google/protobuf/timestamp.d.ts +128 -0
  83. package/dist/esm/generated/google/protobuf/timestamp.js +92 -0
  84. package/dist/esm/generated/protoc-gen-openapiv2/options/annotations.d.ts +1 -0
  85. package/dist/esm/generated/protoc-gen-openapiv2/options/annotations.js +7 -0
  86. package/dist/esm/generated/protoc-gen-openapiv2/options/openapiv2.d.ts +983 -0
  87. package/dist/esm/generated/protoc-gen-openapiv2/options/openapiv2.js +4859 -0
  88. package/dist/esm/generated/tarka/access/v1/access.d.ts +322 -0
  89. package/dist/esm/generated/tarka/access/v1/access.js +2976 -0
  90. package/dist/esm/generated/tarka/channels/v1/channels.d.ts +370 -0
  91. package/dist/esm/generated/tarka/channels/v1/channels.js +3600 -0
  92. package/dist/esm/generated/tarka/gateway/v1/gateway.d.ts +804 -0
  93. package/dist/esm/generated/tarka/gateway/v1/gateway.js +8077 -0
  94. package/dist/esm/generated/tarka/iam/v1/iam.d.ts +1291 -0
  95. package/dist/esm/generated/tarka/iam/v1/iam.js +13203 -0
  96. package/dist/esm/generated/tarka/inference/v1/inference.d.ts +699 -0
  97. package/dist/esm/generated/tarka/inference/v1/inference.js +7055 -0
  98. package/dist/esm/generated/tarka/provisioning/v1/agent_secrets.d.ts +70 -0
  99. package/dist/esm/generated/tarka/provisioning/v1/agent_secrets.js +600 -0
  100. package/dist/esm/generated/tarka/provisioning/v1/billing_quote.d.ts +171 -0
  101. package/dist/esm/generated/tarka/provisioning/v1/billing_quote.js +1585 -0
  102. package/dist/esm/generated/tarka/provisioning/v1/job.d.ts +168 -0
  103. package/dist/esm/generated/tarka/provisioning/v1/job.js +1500 -0
  104. package/dist/esm/generated/tarka/provisioning/v1/provisioning.d.ts +2644 -0
  105. package/dist/esm/generated/tarka/provisioning/v1/provisioning.js +19496 -0
  106. package/dist/esm/generated/tarka/provisioning/v1/registry_credentials.d.ts +89 -0
  107. package/dist/esm/generated/tarka/provisioning/v1/registry_credentials.js +853 -0
  108. package/dist/esm/generated/tarka/provisioning/v1/sandbox.d.ts +431 -0
  109. package/dist/esm/generated/tarka/provisioning/v1/sandbox.js +3192 -0
  110. package/dist/esm/generated/tarka/provisioning/v1/source_builds.d.ts +291 -0
  111. package/dist/esm/generated/tarka/provisioning/v1/source_builds.js +3917 -0
  112. package/dist/esm/grpc.d.ts +12 -0
  113. package/dist/esm/grpc.js +11 -0
  114. package/dist/esm/index.d.ts +6 -0
  115. package/dist/esm/index.js +4 -0
  116. package/dist/esm/resources/inference.d.ts +293 -0
  117. package/dist/esm/resources/inference.js +437 -0
  118. package/dist/esm/resources/provisioning.d.ts +389 -0
  119. package/dist/esm/resources/provisioning.js +531 -0
  120. package/dist/esm/resources/sandboxes.d.ts +360 -0
  121. package/dist/esm/resources/sandboxes.js +718 -0
  122. package/dist/esm/rpc-types.d.ts +36 -0
  123. package/dist/esm/rpc-types.js +26 -0
  124. package/dist/esm/runtime.d.ts +99 -0
  125. package/dist/esm/runtime.js +466 -0
  126. package/dist/esm/transport.d.ts +60 -0
  127. package/dist/esm/transport.js +110 -0
  128. package/dist/esm/types.d.ts +309 -0
  129. package/dist/esm/types.js +1 -0
  130. package/package.json +155 -4
@@ -0,0 +1,110 @@
1
+ import { Client, Metadata, credentials, status, } from "@grpc/grpc-js";
2
+ export function validateTimeout(timeoutMs) {
3
+ if (timeoutMs !== undefined &&
4
+ (!Number.isFinite(timeoutMs) || timeoutMs < 0)) {
5
+ throw new TypeError("timeoutMs must be a finite, non-negative number");
6
+ }
7
+ }
8
+ function prepareCall(options, defaultTimeoutMs) {
9
+ const { timeoutMs = defaultTimeoutMs, signal, metadata, ...grpcOptions } = options;
10
+ validateTimeout(timeoutMs);
11
+ if (timeoutMs !== undefined) {
12
+ const absolute = grpcOptions.deadline instanceof Date
13
+ ? grpcOptions.deadline.getTime()
14
+ : (grpcOptions.deadline ?? Infinity);
15
+ grpcOptions.deadline = Math.min(absolute, Date.now() + timeoutMs);
16
+ }
17
+ if (signal?.aborted)
18
+ throw cancelledError();
19
+ const headers = metadata instanceof Metadata ? metadata.clone() : new Metadata();
20
+ if (metadata && !(metadata instanceof Metadata)) {
21
+ for (const [key, value] of Object.entries(metadata)) {
22
+ for (const item of Array.isArray(value) ? value : [value])
23
+ headers.add(key, item);
24
+ }
25
+ }
26
+ return { signal, metadata: headers, grpcOptions };
27
+ }
28
+ function cancelledError() {
29
+ return Object.assign(new Error("Call cancelled"), {
30
+ code: status.CANCELLED,
31
+ details: "Call cancelled",
32
+ metadata: new Metadata(),
33
+ });
34
+ }
35
+ /**
36
+ * Wrap a generated service definition on a caller-owned channel.
37
+ * The caller remains responsible for closing the channel.
38
+ *
39
+ * @param definition - Generated service definition from a service-specific grpc export.
40
+ * @param channel - Channel whose authentication and lifecycle are managed by the caller.
41
+ * @param defaults - Optional default RPC timeout in milliseconds.
42
+ * @returns Native methods returning promises or lazy async iterables. Empty requests may be omitted; failures retain native gRPC errors.
43
+ */
44
+ export function createServiceClient(definition, channel, defaults = {}) {
45
+ validateTimeout(defaults.timeoutMs);
46
+ const transport = new Client(channel.getTarget(), credentials.createInsecure(), {
47
+ channelOverride: channel,
48
+ });
49
+ const methods = {};
50
+ for (const [key, method] of Object.entries(definition.methods)) {
51
+ if (method.requestStream) {
52
+ throw new TypeError(`Client-streaming RPCs are not supported: ${definition.fullName}/${method.name}`);
53
+ }
54
+ const path = `/${definition.fullName}/${method.name}`;
55
+ const emptyRequest = Object.keys(method.requestType.fromPartial({})).length === 0;
56
+ const argumentsFor = (request, options) => emptyRequest
57
+ ? {
58
+ request: {},
59
+ options: options ?? request ?? {},
60
+ }
61
+ : { request, options: options ?? {} };
62
+ const serialize = (request) => Buffer.from(method.requestType
63
+ .encode(method.requestType.fromPartial(request))
64
+ .finish());
65
+ const deserialize = (bytes) => method.responseType.decode(bytes);
66
+ if (method.responseStream) {
67
+ methods[key] = async function* (input, callOptions) {
68
+ const { request, options } = argumentsFor(input, callOptions);
69
+ const { signal, metadata, grpcOptions } = prepareCall(options, defaults.timeoutMs);
70
+ const call = transport.makeServerStreamRequest(path, serialize, deserialize, request, metadata, grpcOptions);
71
+ const cancel = () => call.cancel();
72
+ signal?.addEventListener("abort", cancel, { once: true });
73
+ // Covers an abort from a synchronous gRPC interceptor during call setup.
74
+ if (signal?.aborted)
75
+ cancel();
76
+ try {
77
+ // Node's readable iterator preserves stream backpressure and gRPC errors.
78
+ for await (const response of call)
79
+ yield response;
80
+ }
81
+ finally {
82
+ signal?.removeEventListener("abort", cancel);
83
+ // A consumer breaking out of for-await must also stop server-side work.
84
+ if (!call.readableEnded)
85
+ call.cancel();
86
+ }
87
+ };
88
+ }
89
+ else {
90
+ methods[key] = async (input, callOptions) => {
91
+ const { request, options } = argumentsFor(input, callOptions);
92
+ const { signal, metadata, grpcOptions } = prepareCall(options, defaults.timeoutMs);
93
+ return new Promise((resolve, reject) => {
94
+ const call = transport.makeUnaryRequest(path, serialize, deserialize, request, metadata, grpcOptions, (error, response) => {
95
+ signal?.removeEventListener("abort", cancel);
96
+ if (error)
97
+ reject(error);
98
+ else
99
+ resolve(response);
100
+ });
101
+ const cancel = () => call.cancel();
102
+ signal?.addEventListener("abort", cancel, { once: true });
103
+ if (signal?.aborted)
104
+ cancel();
105
+ });
106
+ };
107
+ }
108
+ }
109
+ return Object.freeze(methods);
110
+ }
@@ -0,0 +1,309 @@
1
+ import type * as i from "./generated/tarka/inference/v1/inference.js";
2
+ import type * as p from "./generated/tarka/provisioning/v1/provisioning.js";
3
+ import type * as s from "./generated/tarka/provisioning/v1/sandbox.js";
4
+ /** A JSON-compatible value: null, primitive, array, or object. Buffers, Dates, bigint, and undefined are not JSON values. */
5
+ export type JsonValue = null | boolean | number | string | JsonValue[] | JsonObject;
6
+ /** An ordinary JSON object used for OpenAI bodies and extension fields. Narrow dynamic result values before using them in TypeScript. */
7
+ export interface JsonObject {
8
+ [key: string]: JsonValue;
9
+ }
10
+ /** Per-call metadata as a plain object. Values may be strings, Buffers, or arrays; Buffer keys must end in `-bin`. */
11
+ export type Metadata = Readonly<Record<string, string | Buffer | readonly (string | Buffer)[]>>;
12
+ /** Request settings accepted by resource methods. Calls with no input accept these directly; other methods take them after the input. */
13
+ export interface RequestOptions {
14
+ /**
15
+ * Client timeout in milliseconds; overrides the client default. Zero expires immediately.
16
+ *
17
+ * Must be finite and non-negative. Ordinary RPCs have no SDK timeout if both defaults are omitted; streams use one timeout for their entire lifetime. Wait/run helpers use this as a total budget and default to 60,000 ms.
18
+ */
19
+ timeoutMs?: number;
20
+ /** AbortSignal for cancellation. Cancelling a wait stops polling but does not necessarily stop remote execution or undo a mutation. */
21
+ signal?: AbortSignal;
22
+ /** Additional per-call metadata. Use a `-bin` key for Buffer values; inputs are copied into the outgoing request. */
23
+ metadata?: Metadata;
24
+ }
25
+ /** Settings for sandbox readiness, execution waiting, and `run()`. The timeout is a total budget including requests and polling delays, defaulting to 60 seconds. */
26
+ export interface WaitOptions extends RequestOptions {
27
+ /** Delay in milliseconds between incomplete polls. Defaults to 1,000; must be finite and greater than zero. */
28
+ pollIntervalMs?: number;
29
+ }
30
+ /** Convert generated message shapes into public data types, retaining Buffer, Date, and bigint while replacing opaque protobuf values with JsonValue. */
31
+ export type Data<T> = 0 extends 1 & T ? JsonValue : T extends Date | Uint8Array ? T : T extends Array<infer V> ? Data<V>[] : T extends object ? {
32
+ [K in keyof T]: Data<T[K]>;
33
+ } : T;
34
+ /** Build a public request shape: selected keys are required, remaining fields are optional, and scoped/internal fields are omitted. */
35
+ export type Input<T, Required extends keyof T = never, Omitted extends keyof T = never> = {
36
+ [K in Required]: Data<T[K]>;
37
+ } & Partial<Omit<{
38
+ [K in keyof T]: Data<T[K]>;
39
+ }, Required | Omitted>>;
40
+ /** An inference-visible model record. Its `id` can be used in inference requests; 64-bit values such as `created` remain bigint. */
41
+ export type Model = Data<i.Model>;
42
+ /** A control plane model record with provisioning information. Use `modelAlias` for inference requests; catalog `id` is the registry identifier. */
43
+ export type CatalogModel = Data<p.Model>;
44
+ /** A full chat completion, including all choices, usage, and tool calls when provided by the model. */
45
+ export type ChatCompletion = Data<i.ChatCompletion>;
46
+ /** A full streaming chat chunk. Choices may contain text or tool-call deltas; some chunks carry only usage. */
47
+ export type ChatChunk = Data<i.ChatCompletionChunk>;
48
+ /** A named callable function, with optional description, JSON-schema parameters, and model-supported settings. */
49
+ export interface FunctionInput extends Input<i.FunctionDefinition, "name"> {
50
+ /** Function name included in model-generated tool calls. */
51
+ name: string;
52
+ /** Explain what the function does and when the model should call it. */
53
+ description?: string;
54
+ /** JSON Schema describing the arguments accepted by the function. */
55
+ parameters?: JsonObject;
56
+ /** Request strict schema adherence when supported by the model. */
57
+ strict?: boolean;
58
+ }
59
+ /** A function tool with its definition, or a custom tool described by an ordinary JSON object. */
60
+ export type ToolInput = {
61
+ type: "function";
62
+ function: FunctionInput;
63
+ } | {
64
+ type: "custom";
65
+ custom: JsonObject;
66
+ };
67
+ /** A tool call included in a chat message. Function arguments are a JSON-encoded string, not a JavaScript object. */
68
+ export type ToolCallInput = Input<i.ToolCall, "id" | "type", "function"> & {
69
+ function?: {
70
+ name: string;
71
+ arguments: string;
72
+ };
73
+ };
74
+ /** A conversation message with an explicit role and optional content, tool calls, or tool response linkage. */
75
+ export type ChatMessage = Input<i.ChatMessage, never, "role" | "toolCalls"> & {
76
+ /** Role of this message in the conversation. */
77
+ role: "system" | "developer" | "user" | "assistant" | "tool" | "function";
78
+ /** Text or model-supported JSON content parts. Assistant tool-call messages may omit content. */
79
+ content?: JsonValue;
80
+ /** Optional participant name supplied to the model. */
81
+ name?: string;
82
+ /** Tool calls from an assistant message; function arguments are JSON strings. */
83
+ toolCalls?: ToolCallInput[];
84
+ /** For a tool response, the identifier of the assistant tool call being answered. */
85
+ toolCallId?: string;
86
+ };
87
+ /**
88
+ * Typed chat input: choose a prompt with optional system instruction, or a non-empty messages array.
89
+ *
90
+ * Provide a model identifier from inference discovery. Other generation settings are optional and model-dependent; the chosen SDK method sets streaming mode.
91
+ * @example
92
+ * const input = { model: "your-model-alias", prompt: "Hello", maxTokens: 100 };
93
+ */
94
+ export type ChatInput = Input<i.ChatCompletionRequest, "model", "stream" | "messages" | "tools" | "functions"> & {
95
+ /** Inference model identifier or alias, available from `client.models.list()`. */
96
+ model: string;
97
+ /** Requested output token limit. Supported limits and interaction with maxCompletionTokens depend on the model. */
98
+ maxTokens?: number;
99
+ /** Completion token budget, including reasoning tokens for models that count them. Support depends on the model. */
100
+ maxCompletionTokens?: number;
101
+ /** Sampling temperature; lower values generally produce less varied text. Allowed values and defaults depend on the model. */
102
+ temperature?: number;
103
+ /** Nucleus sampling threshold. Support, allowed values, and defaults depend on the model. */
104
+ topP?: number;
105
+ /** Maximum number of candidate tokens considered at each sampling step, when supported. */
106
+ topK?: number;
107
+ /** Repetition penalty passed to models that support it. */
108
+ repeatPenalty?: number;
109
+ /** Penalty for reusing tokens already present in the response, when supported. */
110
+ presencePenalty?: number;
111
+ /** Penalty based on how often a token has appeared in the response, when supported. */
112
+ frequencyPenalty?: number;
113
+ /** Stop sequence or sequences in the model's supported JSON format, commonly a string or array of strings. */
114
+ stop?: JsonValue;
115
+ /** Sampling seed as a bigint, for example `42n`. Repeatability depends on the model and serving configuration. */
116
+ seed?: bigint;
117
+ /** Optional end-user identifier supplied to the inference service. */
118
+ user?: string;
119
+ /** Tools the model may call. Inspect `chat.create()` results for tool calls; the SDK does not execute them. */
120
+ tools?: ToolInput[];
121
+ /** Model-supported tool selection, such as `"auto"`, `"none"`, or a JSON object selecting a tool. */
122
+ toolChoice?: JsonValue;
123
+ /** Legacy function definitions. Prefer tools for models that support tool calls. */
124
+ functions?: FunctionInput[];
125
+ /** Legacy function selection in the model's supported JSON format. */
126
+ functionCall?: JsonValue;
127
+ /** Requested number of choices when supported. Text helpers select choice 0; use create/stream to inspect all choices. */
128
+ n?: number;
129
+ /** Model-supported output format, such as `{ type: "json_object" }` or a JSON Schema configuration. */
130
+ responseFormat?: JsonObject;
131
+ /** Request token log probabilities when supported by the model. */
132
+ logprobs?: boolean;
133
+ /** Number of alternative token log probabilities to request when supported. */
134
+ topLogprobs?: number;
135
+ /** Map of token IDs to model-supported sampling biases. */
136
+ logitBias?: Record<string, number>;
137
+ /** Allow the model to request multiple tool calls in a turn when supported. */
138
+ parallelToolCalls?: boolean;
139
+ /** Streaming response settings; usage-only chunks are available through `chat.stream()`. */
140
+ streamOptions?: {
141
+ /** Ask the server to include usage information in the stream. */
142
+ includeUsage?: boolean;
143
+ /** Request stream obfuscation fields when supported by the service. */
144
+ includeObfuscation?: boolean;
145
+ };
146
+ /** Requested output modalities supported by the model, for example `["text", "audio"]`. */
147
+ modalities?: string[];
148
+ /** Model-supported audio output settings, such as voice and format. */
149
+ audio?: JsonObject;
150
+ /** Model-supported predicted-output configuration. */
151
+ prediction?: JsonObject;
152
+ /** Reasoning effort setting accepted by the selected model. */
153
+ reasoningEffort?: string;
154
+ /** Service tier requested from the inference service, when supported. */
155
+ serviceTier?: string;
156
+ /** Request storage of the completion when the service supports it. */
157
+ store?: boolean;
158
+ /** Application metadata in the model request body. Transport headers belong in the second argument's `metadata` option. */
159
+ metadata?: JsonObject;
160
+ /** Additional model-specific JSON body fields not represented by the typed settings. */
161
+ extraBody?: JsonObject;
162
+ } & ({
163
+ /** User text, converted to a user message. Choose this or messages. */
164
+ prompt: string;
165
+ /** Optional system instruction prepended before the prompt. */
166
+ system?: string;
167
+ messages?: never;
168
+ } | {
169
+ /** Non-empty conversation history. Choose this or prompt/system. */
170
+ messages: ChatMessage[];
171
+ prompt?: never;
172
+ system?: never;
173
+ });
174
+ /** A JSON event from Responses or JSON chat streaming, without a protobuf envelope. */
175
+ export interface ResponseEvent {
176
+ /** Server-provided event name used to distinguish event payloads. */
177
+ type: string;
178
+ /** Event payload as ordinary JSON. Its fields depend on the event type. */
179
+ data: JsonObject;
180
+ }
181
+ /** OCR model and exactly one of `image` or a non-empty `images` array, using model-supported image representations. The SDK chooses streaming mode. */
182
+ export type OcrInput = Input<i.OCRRequest, "model", "stream" | "image" | "images"> & ({
183
+ image: string;
184
+ images?: never;
185
+ } | {
186
+ images: string[];
187
+ image?: never;
188
+ });
189
+ /** Full OCR output, including recognized text and any additional model-provided fields. */
190
+ export type OcrResult = Data<i.OCRResponse>;
191
+ /** One streamed OCR result chunk; `streamText()` extracts its non-empty text. */
192
+ export type OcrChunk = Data<i.OCRChunk>;
193
+ /** Transcription model and audio Buffer in `file`, with optional filename, MIME content type, language, and model settings. */
194
+ export type TranscriptionInput = Input<i.AudioTranscriptionRequest, "file" | "model">;
195
+ /** Translation model and audio Buffer in `file`, with optional filename, MIME content type, and model settings. */
196
+ export type TranslationInput = Input<i.AudioTranslationRequest, "file" | "model">;
197
+ /** Full transcription/translation output. Timing, language, words, and segments are populated when supplied by the model. */
198
+ export type AudioText = Data<i.AudioTextResponse>;
199
+ /** Speech model and text in `input`, plus optional voice, format, speed, instructions, and model-specific JSON settings. */
200
+ export type SpeechInput = Input<i.SpeechRequest, "model" | "input">;
201
+ /** Audio bytes in `data` as a Node Buffer, with the server-provided MIME `contentType`. Used for both collected speech and individual chunks. */
202
+ export type AudioData = Data<i.AudioChunk>;
203
+ /** Voice clone request with model, name, sample Buffer, consent signer, and consent date. Optional filename/contentType describe the sample. */
204
+ export type VoiceInput = Input<i.VoiceCloneRequest, "model" | "name" | "sample" | "consentSignedBy" | "consentDate">;
205
+ /** A voice clone record with its identifier and server-reported lifecycle status. */
206
+ export type Voice = Data<i.VoiceClone>;
207
+ /** Authenticated account information, including organizations and `defaultOrgId` for constructing an organization scope. */
208
+ export type User = Data<p.CurrentUser>;
209
+ /** Organization metadata. Use `client.org(organization.id)` to access its nested resources. */
210
+ export type Organization = Data<p.Org>;
211
+ /** An organization membership with account identifier and role. */
212
+ export type OrganizationMember = Data<p.OrgMember>;
213
+ /** Organization display name and optional globally unique slug; the server allocates an omitted slug. */
214
+ export type OrganizationInput = Input<p.CreateOrgRequest, "name">;
215
+ /** A durable product entitlement request and its current review/access status. */
216
+ export type ProductAccessRequest = Data<p.ProductAccessRequest>;
217
+ /** Product entitlement request details. Organization context is supplied by the scope; omitted contact email uses the authenticated account. */
218
+ export type ProductAccessInput = Input<p.RequestProductAccessRequest, "product", "orgId">;
219
+ /** Optional product and result limit for access requests. The server defaults to 25 records and caps the limit at 100. */
220
+ export type ProductAccessFilter = Input<p.ListProductAccessRequestsRequest, never, "orgId">;
221
+ /** API key metadata without its plaintext secret. List and revoke methods return this shape. */
222
+ export type ApiKey = Data<p.ApiKey>;
223
+ /** API key metadata plus a one-time `secret`. Persist the secret at creation; it is not returned by subsequent list calls. */
224
+ export type CreatedApiKey = ApiKey & {
225
+ /** Plaintext API key returned only at creation. Store it securely for authentication. */
226
+ secret: string;
227
+ };
228
+ /** Optional label, product scopes, and allowed model aliases. Empty model restrictions inherit organization policy; empty scopes use the server's inference default. */
229
+ export type ApiKeyInput = Input<p.CreateApiKeyRequest, never, "orgId">;
230
+ /** Effective inference limits and model policy. Optional absent limits are unlimited; 64-bit budgets use bigint. */
231
+ export type QuotaPolicy = Data<p.QuotaPolicy>;
232
+ /** Complete quota policy replacement. Include every limit to retain; omitted limits become unlimited. Supply model aliases when `allowAllModels` is false. */
233
+ export type QuotaPolicyInput = Input<p.UpdateQuotaPolicyRequest, "allowAllModels", "orgId">;
234
+ /** An inference usage record. 64-bit IDs and counters are bigint so they remain lossless. */
235
+ export type UsageEvent = Data<p.UsageEvent>;
236
+ /** Aggregate organization usage with lossless bigint counters. */
237
+ export type UsageSummary = Data<p.UsageSummary>;
238
+ /** Recorded desired and observed state of managed compute. A creation result does not imply the resource is ready. */
239
+ export type ComputeResource = Data<p.ProvisionedResource>;
240
+ /** Desired inference service configuration with a DNS-label name and model alias; the organization is supplied by the scope. */
241
+ export type InferenceServiceInput = Input<p.CreateInferenceServiceRequest, "name" | "modelAlias", "orgId">;
242
+ /** Desired agent host configuration with a DNS-label name and container image. Extension `spec` must not contain secrets. */
243
+ export type AgentHostInput = Input<p.CreateAgentHostRequest, "name" | "image", "orgId">;
244
+ /** Desired container job configuration. `command` is argv without shell expansion; `timeoutSeconds` controls server execution, separately from client `timeoutMs`. */
245
+ export type JobInput = Input<p.CreateJobRequest, "name" | "image", "orgId">;
246
+ /** An organization storage bucket record, including its stable identifier. */
247
+ export type StorageBucket = Data<p.StorageBucket>;
248
+ /** Bucket credential metadata without its plaintext secret. */
249
+ export type StorageCredential = Data<p.StorageCredential>;
250
+ /** Bucket credential metadata plus access key, one-time secret, endpoint, and region. Persist the secret when created. */
251
+ export type CreatedStorageCredential = StorageCredential & {
252
+ /** Access key identifier used by an S3-compatible client. */
253
+ accessKeyId: string;
254
+ /** One-time plaintext secret. It cannot be retrieved by listing credentials. */
255
+ secretAccessKey: string;
256
+ /** Storage service endpoint for the issued credentials. */
257
+ endpoint: string;
258
+ /** Storage region used with the issued credentials. */
259
+ region: string;
260
+ };
261
+ /** An organization's hosted Git repository record. */
262
+ export type GitRepository = Data<p.GitRepository>;
263
+ /** Hosted repository creation settings; the organization is supplied by the scope. */
264
+ export type GitRepositoryInput = Input<p.CreateGitRepositoryRequest, "name", "orgId">;
265
+ /** The authenticated account's hosted Git identity and reconciliation/access state. */
266
+ export type GitAccess = Data<p.HostedGitAccess>;
267
+ /** Readable sandbox lifecycle state. `unknown` represents an unspecified or unrecognized server enum value. */
268
+ export type SandboxStatus = "starting" | "ready" | "busy" | "stopping" | "stopped" | "failed" | "expired" | "deleted" | "unknown";
269
+ /** Readable template build/deletion state. `unknown` represents an unspecified or unrecognized server enum value. */
270
+ export type TemplateStatus = "pending" | "building" | "ready" | "failed" | "deleting" | "deleted" | "unknown";
271
+ /** Readable execution state. Only `running` is polled; known terminal states, including failures, are returned for inspection. */
272
+ export type ExecutionStatus = "running" | "succeeded" | "failed" | "timed_out" | "cancelled" | "unknown";
273
+ /** Source language used by the template. `unknown` represents an unspecified or unrecognized server value. */
274
+ export type SandboxRuntime = "python" | "node" | "unknown";
275
+ /** A sandbox snapshot with readable status/runtime and Date timestamps. Available through `sandbox.info` and `sandbox.toJSON()`. */
276
+ export type SandboxData = Omit<s.CodeSandbox, "status" | "runtime"> & {
277
+ status: SandboxStatus;
278
+ runtime: SandboxRuntime;
279
+ };
280
+ /** A template snapshot with readable status/runtime, build information, and Date timestamps. */
281
+ export type TemplateData = Omit<s.SandboxTemplate, "status" | "runtime"> & {
282
+ status: TemplateStatus;
283
+ runtime: SandboxRuntime;
284
+ };
285
+ /** An execution snapshot with readable status, retained output, exit code, truncation flag, and timestamps. */
286
+ export type ExecutionData = Omit<s.Execution, "status"> & {
287
+ status: ExecutionStatus;
288
+ };
289
+ /** Sandbox creation settings. `template` accepts a visible ID or alias; `timeoutSeconds` is server lifetime. An omitted idempotency key is generated for recovery. */
290
+ export type SandboxInput = Input<s.CreateCodeSandboxRequest, "template", "orgId">;
291
+ /** Optional stdin, server execution limit in `timeoutSeconds`, and idempotency key. Client wait duration belongs in request options as `timeoutMs`; omitted keys are generated. */
292
+ export type ExecutionInput = Input<s.ExecuteRequest, never, "orgId" | "sandboxId" | "code">;
293
+ /** Custom template alias, built-in base alias, and exactly one dependency manifest string. An omitted idempotency key is generated for recovery. */
294
+ export type TemplateInput = Input<s.CreateSandboxTemplateRequest, "alias" | "baseTemplateAlias", "orgId" | "dependencyFile"> & ({
295
+ /** Contents of requirements.txt, not a file path. Choose exactly one manifest. */
296
+ requirementsTxt: string;
297
+ packageJson?: never;
298
+ pyprojectToml?: never;
299
+ } | {
300
+ /** Contents of package.json as a JSON string, not an object or file path. */
301
+ packageJson: string;
302
+ requirementsTxt?: never;
303
+ pyprojectToml?: never;
304
+ } | {
305
+ /** Contents of pyproject.toml, not a file path. Choose exactly one manifest. */
306
+ pyprojectToml: string;
307
+ requirementsTxt?: never;
308
+ packageJson?: never;
309
+ });
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,157 @@
1
1
  {
2
2
  "name": "@tarkahq/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "The official JavaScript and TypeScript SDK for the Tarka gRPC API",
5
+ "license": "Apache-2.0",
6
+ "author": "Tarka",
7
+ "type": "module",
8
+ "engines": {
9
+ "node": ">=22"
10
+ },
11
+ "main": "./dist/cjs/index.js",
12
+ "module": "./dist/esm/index.js",
13
+ "types": "./dist/esm/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "import": {
17
+ "types": "./dist/esm/index.d.ts",
18
+ "default": "./dist/esm/index.js"
19
+ },
20
+ "require": {
21
+ "types": "./dist/cjs/index.d.ts",
22
+ "default": "./dist/cjs/index.js"
23
+ }
24
+ },
25
+ "./grpc": {
26
+ "import": {
27
+ "types": "./dist/esm/grpc.d.ts",
28
+ "default": "./dist/esm/grpc.js"
29
+ },
30
+ "require": {
31
+ "types": "./dist/cjs/grpc.d.ts",
32
+ "default": "./dist/cjs/grpc.js"
33
+ }
34
+ },
35
+ "./grpc/inference/v1": {
36
+ "import": {
37
+ "types": "./dist/esm/generated/tarka/inference/v1/inference.d.ts",
38
+ "default": "./dist/esm/generated/tarka/inference/v1/inference.js"
39
+ },
40
+ "require": {
41
+ "types": "./dist/cjs/generated/tarka/inference/v1/inference.d.ts",
42
+ "default": "./dist/cjs/generated/tarka/inference/v1/inference.js"
43
+ }
44
+ },
45
+ "./grpc/provisioning/v1": {
46
+ "import": {
47
+ "types": "./dist/esm/generated/tarka/provisioning/v1/provisioning.d.ts",
48
+ "default": "./dist/esm/generated/tarka/provisioning/v1/provisioning.js"
49
+ },
50
+ "require": {
51
+ "types": "./dist/cjs/generated/tarka/provisioning/v1/provisioning.d.ts",
52
+ "default": "./dist/cjs/generated/tarka/provisioning/v1/provisioning.js"
53
+ }
54
+ },
55
+ "./grpc/sandboxes/v1": {
56
+ "import": {
57
+ "types": "./dist/esm/generated/tarka/provisioning/v1/sandbox.d.ts",
58
+ "default": "./dist/esm/generated/tarka/provisioning/v1/sandbox.js"
59
+ },
60
+ "require": {
61
+ "types": "./dist/cjs/generated/tarka/provisioning/v1/sandbox.d.ts",
62
+ "default": "./dist/cjs/generated/tarka/provisioning/v1/sandbox.js"
63
+ }
64
+ },
65
+ "./package.json": "./package.json",
66
+ "./grpc/iam/v1": {
67
+ "import": {
68
+ "types": "./dist/esm/generated/tarka/iam/v1/iam.d.ts",
69
+ "default": "./dist/esm/generated/tarka/iam/v1/iam.js"
70
+ },
71
+ "require": {
72
+ "types": "./dist/cjs/generated/tarka/iam/v1/iam.d.ts",
73
+ "default": "./dist/cjs/generated/tarka/iam/v1/iam.js"
74
+ }
75
+ },
76
+ "./grpc/gateway/v1": {
77
+ "import": {
78
+ "types": "./dist/esm/generated/tarka/gateway/v1/gateway.d.ts",
79
+ "default": "./dist/esm/generated/tarka/gateway/v1/gateway.js"
80
+ },
81
+ "require": {
82
+ "types": "./dist/cjs/generated/tarka/gateway/v1/gateway.d.ts",
83
+ "default": "./dist/cjs/generated/tarka/gateway/v1/gateway.js"
84
+ }
85
+ },
86
+ "./grpc/access/v1": {
87
+ "import": {
88
+ "types": "./dist/esm/generated/tarka/access/v1/access.d.ts",
89
+ "default": "./dist/esm/generated/tarka/access/v1/access.js"
90
+ },
91
+ "require": {
92
+ "types": "./dist/cjs/generated/tarka/access/v1/access.d.ts",
93
+ "default": "./dist/cjs/generated/tarka/access/v1/access.js"
94
+ }
95
+ },
96
+ "./grpc/channels/v1": {
97
+ "import": {
98
+ "types": "./dist/esm/generated/tarka/channels/v1/channels.d.ts",
99
+ "default": "./dist/esm/generated/tarka/channels/v1/channels.js"
100
+ },
101
+ "require": {
102
+ "types": "./dist/cjs/generated/tarka/channels/v1/channels.d.ts",
103
+ "default": "./dist/cjs/generated/tarka/channels/v1/channels.js"
104
+ }
105
+ }
106
+ },
107
+ "files": [
108
+ "dist",
109
+ "README.md",
110
+ "LICENSE",
111
+ "NOTICE",
112
+ "api-source.json"
113
+ ],
114
+ "sideEffects": false,
115
+ "publishConfig": {
116
+ "access": "public",
117
+ "registry": "https://registry.npmjs.org/"
118
+ },
119
+ "repository": {
120
+ "type": "git",
121
+ "url": "git+https://github.com/TarkaHQ/sdk-javascript.git"
122
+ },
123
+ "homepage": "https://github.com/TarkaHQ/sdk-javascript#readme",
124
+ "bugs": "https://github.com/TarkaHQ/sdk-javascript/issues",
125
+ "keywords": [
126
+ "tarka",
127
+ "sdk",
128
+ "grpc",
129
+ "typescript",
130
+ "inference",
131
+ "sandboxes"
132
+ ],
133
+ "scripts": {
134
+ "generate": "node scripts/generate.mjs",
135
+ "check:generated": "node scripts/generate.mjs --check",
136
+ "build": "node scripts/build.mjs",
137
+ "typecheck": "tsc --noEmit && tsc -p tsconfig.tests.json",
138
+ "test": "tsx --test tests/*.test.ts",
139
+ "test:package": "node scripts/test-package.mjs",
140
+ "format": "prettier --write .",
141
+ "format:check": "prettier --check .",
142
+ "verify": "npm run format:check && npm run typecheck && npm test && npm run build && npm run test:package",
143
+ "prepack": "npm run build"
144
+ },
145
+ "dependencies": {
146
+ "@bufbuild/protobuf": "^2.16.0",
147
+ "@grpc/grpc-js": "^1.14.5"
148
+ },
149
+ "devDependencies": {
150
+ "@types/node": "22.20.4",
151
+ "grpc-tools": "1.13.1",
152
+ "prettier": "3.9.9",
153
+ "ts-proto": "2.12.4",
154
+ "tsx": "4.23.15",
155
+ "typescript": "5.9.3"
156
+ }
157
+ }