@opengeni/runtime 4.4.0 → 4.5.0-canary.36935312914001

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.
@@ -14,6 +14,7 @@ export declare function createFirstPartyAttemptClient(input: {
14
14
  };
15
15
  selectedTools: readonly FirstPartyMcpToolName[];
16
16
  permissions?: readonly Permission[];
17
+ credentialRestriction?: "developer_setup";
17
18
  fetch?: typeof fetch;
18
19
  signal?: AbortSignal;
19
20
  }): OpenGeniClient;
package/dist/index.d.ts CHANGED
@@ -752,6 +752,8 @@ export type PrepareToolsOptions = {
752
752
  executionGeneration?: number;
753
753
  subjectId?: string;
754
754
  subjectLabel?: string;
755
+ /** Trusted immutable setup ceiling from the accepted execution policy. */
756
+ credentialRestriction?: "developer_setup";
755
757
  credentialSubjectId?: string;
756
758
  initiatingHumanSubjectId?: string | null;
757
759
  initiatingHumanExternalIdentity?: {
package/dist/index.js CHANGED
@@ -294,7 +294,7 @@ import {
294
294
  workspaceEnvironmentInstructions,
295
295
  wrapAttemptToolDefinitions,
296
296
  wrapAttemptToolExecute
297
- } from "./chunk-BOBZ4N56.js";
297
+ } from "./chunk-ETKOJALF.js";
298
298
  import {
299
299
  ActiveBackendUnresolvableError,
300
300
  BROWSER_CONTROL_ADMIN_TOKEN_FILE,
@@ -573,7 +573,7 @@ import {
573
573
  withRunCredentialsClient,
574
574
  withRunCredentialsSession,
575
575
  withoutSandboxProviderIdentity
576
- } from "./chunk-QKROIZOB.js";
576
+ } from "./chunk-VDXKKMMD.js";
577
577
  import "./chunk-7KVMU7O3.js";
578
578
  import "./chunk-4A4XTKKX.js";
579
579
  import "./chunk-GUJMCB7F.js";
@@ -23,6 +23,7 @@ export type CreateFirstPartyInteractionAttemptToolsInput = Omit<CreateInteractio
23
23
  scope: AttemptToolScope;
24
24
  subjectId?: string;
25
25
  subjectLabel?: string;
26
+ credentialRestriction?: "developer_setup";
26
27
  fetch?: typeof globalThis.fetch;
27
28
  };
28
29
  /**
@@ -9,6 +9,7 @@ export type SandboxCodemodeAuthority = {
9
9
  turnId: string;
10
10
  attemptId: string;
11
11
  executionGeneration: number;
12
+ credentialRestriction?: "developer_setup";
12
13
  };
13
14
  export type MintedSandboxCodemodeToken = {
14
15
  token: string;
@@ -274,7 +274,7 @@ import {
274
274
  withRunCredentialsClient,
275
275
  withRunCredentialsSession,
276
276
  withoutSandboxProviderIdentity
277
- } from "../chunk-QKROIZOB.js";
277
+ } from "../chunk-VDXKKMMD.js";
278
278
  import "../chunk-7KVMU7O3.js";
279
279
  import "../chunk-4A4XTKKX.js";
280
280
  import "../chunk-GUJMCB7F.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  prepareAgentTools
3
- } from "./chunk-BOBZ4N56.js";
4
- import "./chunk-QKROIZOB.js";
3
+ } from "./chunk-ETKOJALF.js";
4
+ import "./chunk-VDXKKMMD.js";
5
5
  import "./chunk-7KVMU7O3.js";
6
6
  import "./chunk-4A4XTKKX.js";
7
7
  import "./chunk-GUJMCB7F.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/runtime",
3
- "version": "4.4.0",
3
+ "version": "4.5.0-canary.36935312914001",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -63,17 +63,17 @@
63
63
  "@openai/agents": "0.14.3",
64
64
  "@openai/agents-core": "0.14.3",
65
65
  "@openai/agents-extensions": "0.14.3",
66
- "@opengeni/agent-proto": "^0.6.1",
67
- "@opengeni/capabilities": "^0.3.5",
68
- "@opengeni/codemode": "^0.6.6",
69
- "@opengeni/codex": "^0.2.30",
70
- "@opengeni/config": "^3.2.0",
71
- "@opengeni/contracts": "^5.5.0",
72
- "@opengeni/network": "^0.3.1",
73
- "@opengeni/observability": "^0.8.36",
74
- "@opengeni/sdk": "^7.5.0",
75
- "@opengeni/tool-gateway": "^0.1.17",
76
- "@opengeni/xai-subscription": "^0.1.5",
66
+ "@opengeni/agent-proto": "^0.6.1-canary.36935312914001",
67
+ "@opengeni/capabilities": "^0.3.5-canary.36935312914001",
68
+ "@opengeni/codemode": "^0.6.7-canary.36935312914001",
69
+ "@opengeni/codex": "^0.2.31-canary.36935312914001",
70
+ "@opengeni/config": "^3.2.1-canary.36935312914001",
71
+ "@opengeni/contracts": "^5.6.0-canary.36935312914001",
72
+ "@opengeni/network": "^0.3.1-canary.36935312914001",
73
+ "@opengeni/observability": "^0.8.37-canary.36935312914001",
74
+ "@opengeni/sdk": "^7.6.0-canary.36935312914001",
75
+ "@opengeni/tool-gateway": "^0.1.18-canary.36935312914001",
76
+ "@opengeni/xai-subscription": "^0.1.5-canary.36935312914001",
77
77
  "debug": "4.4.3",
78
78
  "modal": "0.9.0",
79
79
  "openai": "6.47.0",
@@ -18,6 +18,12 @@ Use this skill when a customer's product and OpenGeni remain separate systems.
18
18
  That is the normal integration shape: the product owns its users and business
19
19
  UI, while a standalone OpenGeni deployment owns agent sessions and execution.
20
20
 
21
+ For first-time organization and workspace provisioning, start with
22
+ [OpenGeni developer setup](https://docs.opengeni.ai/guides/developer-plugin), then return here to write
23
+ the embedding code. That skills-only workflow uses the coding agent's own
24
+ browser and public REST/SDK, with a scoped Developer setup key; no OpenGeni MCP
25
+ server is required.
26
+
21
27
  Do not confuse two meanings of "skill": this file teaches a customer's coding
22
28
  agent how to integrate OpenGeni; session `skills` are runtime capabilities or
23
29
  instructions attached to an OpenGeni agent. The former designs the integration.
@@ -196,7 +202,10 @@ Choose one only for its stated reason; read
196
202
  materially different interaction model but still wants canonical event,
197
203
  queue, composer, approval, and human-input behavior.
198
204
  - **SDK only**: a non-React frontend (Svelte, Vue, native mobile), a CLI, or
199
- backend automation. Keep the SDK on a product backend route.
205
+ backend automation. Keep the SDK on a product backend route. For a runnable
206
+ native Vue host, start with the
207
+ [Vue conversation recipe](https://github.com/Cloudgeni-ai/opengeni/blob/main/examples/vue-conversation/README.md).
208
+ Run its consumer commands from `examples/vue-conversation/app`.
200
209
  - **A non-JavaScript backend** (Django, Rails, Go, PHP, Java): keep the React
201
210
  conversation and implement the proxy's small HTTP contract in that backend
202
211
  instead of adding a Node sidecar. See
@@ -30,12 +30,22 @@ export const POST = createChatHandler(og, {
30
30
  return me ? { tenant: me.accountId, user: me.userId } : new Response("Unauthorized", { status: 401 });
31
31
  },
32
32
  format: "vercel", // or "openai-chat" / "openai-responses"; default: native chunks
33
+ toolParts: true, // optional Vercel activity indicators; off by default
33
34
  });
34
35
 
35
36
  const chat = await og.chat({ tenant: "acme", user: "u_42", conversation: "c_9" });
36
37
  const reply = await chat.send("hello"); // reply.text; chat.stream(...) yields chunks
37
38
  ```
38
39
 
40
+ For the Vercel format, `toolParts: true` emits OpenGeni's tool activity as
41
+ `dynamic`, `providerExecuted` parts, not tools for your app to execute. The
42
+ successful output is only `{ status }`, not the actual result: this opt-in does
43
+ not restore tool results, artifacts or attachments. Leave it off for text-only
44
+ activity. Approval requests are emitted independently of this option (AI SDK
45
+ 6+ is needed to answer them). When composing your own AI SDK stream, pass the
46
+ same option to `uiMessageStreamParts(chunks, { framing: false, toolParts: true })`;
47
+ `framing: false` leaves message framing to the outer stream.
48
+
39
49
  Each tenant maps to one workspace and each conversation to one deterministic
40
50
  session. Conversation IDs are independent of the acting user; authorization
41
51
  decides who may use a shared conversation. Without a `user`, `resolve` must
@@ -14,6 +14,39 @@ Documentation availability and deployed feature availability are separate.
14
14
  Inspect the installed package exports/types and `/v1/config/client`; verify the
15
15
  chosen contract against the intended deployment before implementing against it.
16
16
 
17
+ To check the full Skill's HTTP Markdown export from a repository checkout:
18
+
19
+ ```bash
20
+ bun scripts/check-client-skill-markdown-export.ts
21
+ ```
22
+
23
+ This opt-in network check compares the published `.md` sections with the local
24
+ generated mirror, including nested code fences. A mismatch may mean the docs
25
+ deployment has not caught up with the checkout; it is not evidence of a runtime
26
+ API failure. Use `--url` and `--expected` to check another deployment or a known
27
+ matching mirror. The local HTTP regression tests run without external services.
28
+
29
+ ## CommonJS hosts
30
+
31
+ The SDK is ESM-only. In an existing `.cjs` host, use dynamic `import()` inside
32
+ an async initializer; `require("@opengeni/sdk")` is not the supported loading
33
+ path. Do not change the entire project's module type just to load the SDK.
34
+
35
+ ```js
36
+ // opengeni.cjs — callers await createOpenGeniClient().
37
+ async function createOpenGeniClient() {
38
+ const { OpenGeniClient } = await import("@opengeni/sdk");
39
+ return new OpenGeniClient({
40
+ baseUrl: process.env.OPENGENI_API_BASE_URL,
41
+ apiKey: process.env.OPENGENI_API_KEY,
42
+ });
43
+ }
44
+
45
+ module.exports = { createOpenGeniClient };
46
+ ```
47
+
48
+ Keep this initialization on the server: never send the API key to a browser.
49
+
17
50
  ## Decide what is being replaced
18
51
 
19
52
  | Customer dependency | Evidence needed |
@@ -214,10 +214,35 @@ Rules the server enforces:
214
214
 
215
215
  ## Verify
216
216
 
217
+ Read response visibility from `session.tenancy?.visibility`, not
218
+ `session.visibility`. The top-level `visibility` field belongs to create
219
+ requests; the response's tenancy projection may be absent when private-session
220
+ support is unavailable. Absence means unknown, not `"workspace"`.
221
+
222
+ `effectiveTools.tools` is a flat list, not a capability-keyed object. Group it
223
+ locally if your UI needs capability sections:
224
+
225
+ ```ts
226
+ import type { AgentEffectiveTools } from "@opengeni/sdk";
227
+
228
+ const session = await og.getSession(workspaceId, sessionId);
229
+ const visibility = session.tenancy?.visibility; // "private" | "workspace" | undefined
230
+ const byCapability = new Map<string, AgentEffectiveTools["tools"]>();
231
+ for (const tool of session.effectiveTools?.tools ?? []) {
232
+ const group = byCapability.get(tool.capability) ?? [];
233
+ group.push(tool);
234
+ byCapability.set(tool.capability, group);
235
+ }
236
+ const knowledgeTools = byCapability.get("knowledge") ?? [];
237
+ ```
238
+
239
+ An absent `effectiveTools` projection on an older session means the inventory is
240
+ unknown, not that every capability is off. Each tool's `visibility` means model
241
+ discovery (`"upfront"` or `"search"`), not who can see the session. Preserve it
242
+ when grouping. `mcpServers[].toolsKnown: false` means that server's schemas are
243
+ not known in this projection; do not invent tool names or treat it as disabled.
244
+
217
245
  - `session.agent`: the resolved configuration, including `source` (request,
218
246
  workspace default, inherited, ...) and `unavailable`.
219
- - `session.effectiveTools.tools`: every known tool with its capability and
220
- `visibility: "upfront" | "search"`. `mcpServers[].toolsKnown: false` means that
221
- server lists its tools when a turn starts.
222
247
  - The model-context inspector in the OpenGeni web app (session > Debug >
223
248
  Context) shows the instructions actually sent, split into titled sections.
@@ -40,7 +40,7 @@ The normal workspace-scoped API Integration flow is deterministic control-plane
40
40
  2. Create or resolve the appropriate encrypted Connection when authentication is required. An `api_key` Connection must say where the secret goes: `credential: { headers: { Authorization: "Token ..." } }`, or `credential: { placements: [{ carrier: "header" | "query" | "cookie", name, value, prefix? }] }` (query and cookie placements work for API Integrations only). Match `preview.auth.carrier`/`name` from step 3; a bare `{ apiKey }` is rejected with 422, and preview adds a warning when the Connection's placement differs from the description.
41
41
  3. Call previewApiIntegration with the source and, when needed, the Connection. The source can be a URL or an inline document: `{ kind: "openapi_document", sourceKey: "<stable id>", document: "<OpenAPI JSON/YAML>", baseUrl? }` (8 MiB max, absolute server URLs or `baseUrl`; resend it on install; the preview echoes only its digest). Inlining does not make a localhost or private API reachable: tool calls still follow the deployment network policy, so a local product needs a public tunnel.
42
42
  4. Apply the customer's policy to the compiled operation list, safety classification, warnings, and approval modes. Select only intended operations.
43
- 5. Call installApiIntegration with the exact preview revision and content digest, Connection, stable instance key, and allowed operations. Write and destructive operations (preview `approvalMode: "ask"`) otherwise pause every call for human approval, which a scheduled or unattended run cannot give; list the ones your policy allows to run unattended in `autoApprovedTools` (`capabilities:manage`; custom and curated Integrations alike, except operations a curated definition explicitly keeps human-approved). The field is declarative: an update that omits it makes every write tool ask again. MCP connector tool permissions and session `mcpApprovalPolicies` do not apply to API Integrations.
43
+ 5. Call installApiIntegration with the exact preview revision and content digest, Connection, stable instance key, and allowed operations. Write and destructive operations (preview `approvalMode: "ask"`) otherwise pause every call for human approval, which a scheduled or unattended run cannot give; list the ones your policy allows to run unattended in `autoApprovedTools` (`capabilities:manage`; custom and curated Integrations alike, except operations a curated definition explicitly keeps human-approved). Use the exact compiled identifiers from `preview.tools[].id`, not a guessed OpenAPI operationId or model-facing prefixed name. The field is declarative: an update that omits it makes every write tool ask again. MCP connector tool permissions and session `mcpApprovalPolicies` do not apply to API Integrations.
44
44
  6. Persist the returned non-secret instance and server identifiers with the workspace provisioning record, then select that server for sessions: omit `tools` to follow the workspace defaults, or list it explicitly as `tools: [{ kind: "mcp", id: serverId }]`. An explicit `tools` array is an exact allow-list; `[]` selects no workspace server.
45
45
 
46
46
  Preview and install are ordinary backend API calls and can be automated. Human review is required only when the customer's policy or the operation risk requires it. The immutable revision/digest fence ensures that automation cannot install a different schema from the one it evaluated.
@@ -53,6 +53,13 @@ An agent-focused API description is often helpful: concise descriptions, stable
53
53
 
54
54
  A workspace MCP capability is suitable when many sessions in that workspace use the same server and authority. A session may also receive an explicit mcpServers definition with URL, allowed tools, approval policy, and write-only credential headers or a non-secret Connection reference.
55
55
 
56
+ For a per-session MCP server, `requireApproval: ["update_ticket"]` matches the
57
+ original tool name returned by the server's `tools/list`, not the model-facing
58
+ `acme__update_ticket` name (for server id `acme`). `true` gates every tool.
59
+ This MCP name list is distinct from an API Integration's compiled
60
+ `autoApprovedTools` identifiers; a session MCP policy does not override an API
61
+ Integration's install-time approval policy.
62
+
56
63
  A server attached through a top-level createSession `mcpServers` entry is selected by that attachment, whether `tools` is omitted or explicit (including `tools: []`); there is no separate selection step. Every other MCP server (workspace capability, installed API Integration, deployment server) is reachable only when `tools` selects it or the omitted-`tools` workspace default includes it. A selected server the model never finds usually means it was not selected: check `session.effectiveToolPolicy`.
57
64
 
58
65
  Selected MCP servers are prepared lazily by default: the model discovers their tools through `tool_search`. For a small, always-needed server (for example a product's own data tools), add `eager: true` to its ref, such as `tools: [{ kind: "mcp", id: "product", eager: true }]`, so its schemas are on the first model request. `eager` is a startup choice only and grants nothing. `optional: true` makes a connect or list failure skip that server instead of failing the demanding turn.
@@ -16,8 +16,18 @@ Default to the full conversation component. Deviate only when the product needs
16
16
 
17
17
  Inspect the installed OpenGeni React package before creating replacement components. Its subpaths are composable, and the styled surfaces use scoped compiled CSS plus runtime theme and density tokens. Prefer, in order: `SessionConversation` customized through `composerProps` and `renderMessageText`; `MessageTimeline`, `ChatComposer`, and the session hooks composed into product layout; then a fully custom SDK-driven UI. Do not force a packaged component when the product needs a materially different interaction model.
18
18
 
19
+ ## Native non-React frontends
20
+
19
21
  For Svelte, SvelteKit, Vue, native mobile, or another non-React frontend, use the product's native component system. Keep the privileged OpenGeni client on a compatible backend boundary. A SvelteKit server route may use the TypeScript SDK directly; a non-JavaScript backend may use the public HTTP contract or a small compatible adapter. The browser still speaks to authenticated product routes.
20
22
 
23
+ Start with the [runnable Vue conversation recipe](https://github.com/Cloudgeni-ai/opengeni/blob/main/examples/vue-conversation/README.md)
24
+ for native Vue single-file components, Vite and the existing Bun Fetch session
25
+ proxy using the published SDK. Follow the README's deployment and host-auth
26
+ prerequisites; run install, onboarding and consumer checks from
27
+ `examples/vue-conversation/app`, not the repository root. The sample handles
28
+ durable conversations and decisions with an escaped-text UI, not a full rich
29
+ Markdown, artifact or file renderer. Keep organization credentials server-only.
30
+
21
31
  ## Links, downloads, artifacts, and Sites
22
32
 
23
33
  Agent replies link OpenGeni objects as `artifact:<file uuid>`,
@@ -25,6 +25,7 @@ export function createFirstPartyAttemptClient(input: {
25
25
  };
26
26
  selectedTools: readonly FirstPartyMcpToolName[];
27
27
  permissions?: readonly Permission[];
28
+ credentialRestriction?: "developer_setup";
28
29
  fetch?: typeof fetch;
29
30
  signal?: AbortSignal;
30
31
  }) {
@@ -53,6 +54,9 @@ export function createFirstPartyAttemptClient(input: {
53
54
  principalKind: "agent_attempt",
54
55
  permissions: [...(input.permissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS)],
55
56
  firstPartyMcpTools: [...input.selectedTools],
57
+ ...(input.credentialRestriction
58
+ ? { credentialRestriction: input.credentialRestriction }
59
+ : {}),
56
60
  exp: Math.floor(Date.now() / 1_000) + 60 * 60,
57
61
  });
58
62
  const headers = new Headers(init?.headers);
package/src/index.ts CHANGED
@@ -4120,6 +4120,8 @@ export type PrepareToolsOptions = {
4120
4120
  executionGeneration?: number;
4121
4121
  subjectId?: string;
4122
4122
  subjectLabel?: string;
4123
+ /** Trusted immutable setup ceiling from the accepted execution policy. */
4124
+ credentialRestriction?: "developer_setup";
4123
4125
  // Immutable human authority used only for subject-owned connection lookup.
4124
4126
  // This is intentionally separate from the worker's first-party MCP identity.
4125
4127
  credentialSubjectId?: string;
@@ -6871,6 +6873,9 @@ async function signFirstPartyDelegatedBearer(
6871
6873
  workspaceId: options.workspaceId,
6872
6874
  subjectId: options.subjectId ?? "worker:first-party-mcp",
6873
6875
  ...(options.subjectLabel ? { subjectLabel: options.subjectLabel } : {}),
6876
+ ...(options.credentialRestriction
6877
+ ? { credentialRestriction: options.credentialRestriction }
6878
+ : {}),
6874
6879
  permissions: options.firstPartyPermissions ?? [...DEFAULT_FIRST_PARTY_MCP_PERMISSIONS],
6875
6880
  principalKind: hasExactAttemptClaims ? "agent_attempt" : "service",
6876
6881
  firstPartyMcpTools: options.firstPartyTools ?? [...DEFAULT_FIRST_PARTY_MCP_TOOLS],
@@ -1478,6 +1478,7 @@ export type CreateFirstPartyInteractionAttemptToolsInput = Omit<
1478
1478
  scope: AttemptToolScope;
1479
1479
  subjectId?: string;
1480
1480
  subjectLabel?: string;
1481
+ credentialRestriction?: "developer_setup";
1481
1482
  fetch?: typeof globalThis.fetch;
1482
1483
  };
1483
1484
 
@@ -1518,6 +1519,9 @@ export function createFirstPartyInteractionAttemptToolDefinitions(
1518
1519
  turnId: input.scope.turnId,
1519
1520
  attemptId: input.scope.attemptId,
1520
1521
  executionGeneration: input.scope.executionGeneration,
1522
+ ...(input.credentialRestriction
1523
+ ? { credentialRestriction: input.credentialRestriction }
1524
+ : {}),
1521
1525
  exp: Math.floor(Date.now() / 1_000) + 60 * 60,
1522
1526
  });
1523
1527
  const headers = new Headers(init?.headers);
@@ -13,6 +13,7 @@ export type SandboxCodemodeAuthority = {
13
13
  turnId: string;
14
14
  attemptId: string;
15
15
  executionGeneration: number;
16
+ credentialRestriction?: "developer_setup";
16
17
  };
17
18
 
18
19
  export type MintedSandboxCodemodeToken = {
@@ -45,6 +46,9 @@ export async function mintSandboxCodemodeToken(
45
46
  turnId: authority.turnId,
46
47
  attemptId: authority.attemptId,
47
48
  executionGeneration: authority.executionGeneration,
49
+ ...(authority.credentialRestriction
50
+ ? { credentialRestriction: authority.credentialRestriction }
51
+ : {}),
48
52
  principalKind: "agent_attempt",
49
53
  exp: expiresAtSeconds,
50
54
  });
@@ -330,7 +330,10 @@ export class ModalCommandControl {
330
330
  async verifyExecReadiness(signal: AbortSignal): Promise<number> {
331
331
  signal.throwIfAborted();
332
332
  const sandboxId = this.sandboxId;
333
- const task = await this.client.sandboxGetTaskId({ sandboxId }, { signal });
333
+ const task = await ModalCommandStartPreDispatchUnavailableError.beforeDispatch(
334
+ () => this.client.sandboxGetTaskId({ sandboxId }, { signal }),
335
+ signal,
336
+ );
334
337
  if (!task.taskId || task.taskResult) throw new Error("Modal command task is unavailable");
335
338
  if (sandboxId !== this.sandboxId)
336
339
  throw new Error("Modal sandbox changed during readiness preparation");
@@ -340,7 +343,7 @@ export class ModalCommandControl {
340
343
  (error as { code?: number } | null)?.code ?? -1,
341
344
  );
342
345
  const pause = () => delay(100, undefined, { signal });
343
- return await this.withRouter(task.taskId, signal, async (router) => {
346
+ return await this.withStartRouter(task.taskId, signal, async (router) => {
344
347
  for (;;) {
345
348
  signal.throwIfAborted();
346
349
  try {