@giselles-ai/agent 0.1.25 → 0.1.26

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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AgentConfig, D as DefinedAgent } from './types-cRejduhB.js';
2
- export { a as AgentFile, b as AgentSetup } from './types-cRejduhB.js';
1
+ import { A as AgentConfig, D as DefinedAgent } from './types-Co_KfALw.js';
2
+ export { a as AgentFile, b as AgentSetup, U as UICatalog } from './types-Co_KfALw.js';
3
3
 
4
4
  declare function defineAgent(config: AgentConfig): DefinedAgent;
5
5
 
package/dist/index.js CHANGED
@@ -5,11 +5,18 @@ import {
5
5
 
6
6
  // src/define-agent.ts
7
7
  function defineAgent(config) {
8
+ const catalogPrompt = config.catalog?.prompt({ mode: "inline" });
9
+ const agentMd = [config.agentMd, catalogPrompt].filter(Boolean).join("\n\n");
8
10
  return {
9
11
  agentType: config.agentType ?? "gemini",
10
- agentMd: config.agentMd,
12
+ agentMd: agentMd || void 0,
13
+ catalog: config.catalog,
11
14
  files: config.files ?? [],
12
- env: config.env ?? {},
15
+ env: config.env ? Object.fromEntries(
16
+ Object.entries(config.env).filter(
17
+ (entry) => entry[1] != null
18
+ )
19
+ ) : {},
13
20
  setup: config.setup,
14
21
  get snapshotId() {
15
22
  const id = process.env?.GISELLE_AGENT_SNAPSHOT_ID;
@@ -1,5 +1,5 @@
1
1
  import { NextConfig } from 'next';
2
- import { A as AgentConfig } from '../types-cRejduhB.js';
2
+ import { A as AgentConfig } from '../types-Co_KfALw.js';
3
3
 
4
4
  type GiselleAgentPluginOptions = {
5
5
  /** Base URL for the agent API. Default: process.env.GISELLE_AGENT_BASE_URL ?? "https://studio.giselles.ai/agent-api" */
@@ -537,11 +537,19 @@ function createGeminiAgent(options = {}) {
537
537
  "--output-format",
538
538
  "stream-json",
539
539
  "--approval-mode",
540
- "yolo"
540
+ "yolo",
541
+ "--sandbox",
542
+ "false"
541
543
  ];
542
544
  if (input.session_id) {
543
545
  args.push("--resume", input.session_id);
544
546
  }
547
+ console.info("[gemini-agent] createCommand", {
548
+ hasSessionId: Boolean(input.session_id),
549
+ hasSandboxId: Boolean(input.sandbox_id),
550
+ hasSnapshotId: Boolean(input.snapshot_id),
551
+ argCount: args.length
552
+ });
545
553
  return {
546
554
  cmd: "gemini",
547
555
  args,
@@ -597,6 +605,7 @@ function createAgent(options) {
597
605
  // src/chat-run.ts
598
606
  import { Writable } from "stream";
599
607
  import { Sandbox as Sandbox2 } from "@vercel/sandbox";
608
+ var COMMAND_TIMEOUT_EXTENSION_MS = 5 * 60 * 1e3;
600
609
  function emitText(controller, text, encoder) {
601
610
  if (text.length === 0) {
602
611
  return;
@@ -666,7 +675,21 @@ function runChat(input) {
666
675
  const sandbox = await (async () => {
667
676
  if (parsed.sandbox_id) {
668
677
  try {
669
- return await Sandbox2.get({ sandboxId: parsed.sandbox_id });
678
+ const existing = await Sandbox2.get({
679
+ sandboxId: parsed.sandbox_id
680
+ });
681
+ if (existing.status !== "running") {
682
+ if (!snapshotId) {
683
+ throw new Error(
684
+ `Sandbox ${parsed.sandbox_id} is ${existing.status}, not running`
685
+ );
686
+ }
687
+ console.log(
688
+ `[sandbox] sandbox=${parsed.sandbox_id} status=${existing.status}, recreating from snapshot=${snapshotId}`
689
+ );
690
+ return createFromSnapshot(snapshotId);
691
+ }
692
+ return existing;
670
693
  } catch (error) {
671
694
  if (!snapshotId) {
672
695
  throw error;
@@ -692,6 +715,16 @@ function runChat(input) {
692
715
  const command = input.agent.createCommand({
693
716
  input: parsed
694
717
  });
718
+ console.info("[chat-run] starting sandbox command", {
719
+ sandboxId: sandbox.sandboxId,
720
+ cmd: command.cmd,
721
+ args: command.args,
722
+ envKeys: Object.keys(command.env ?? {}).sort(),
723
+ hasSessionId: typeof parsed.session_id === "string" && parsed.session_id.length > 0,
724
+ hasSandboxId: typeof parsed.sandbox_id === "string" && parsed.sandbox_id.length > 0,
725
+ hasSnapshotId: typeof parsed.snapshot_id === "string" && parsed.snapshot_id.length > 0
726
+ });
727
+ await sandbox.extendTimeout(COMMAND_TIMEOUT_EXTENSION_MS);
695
728
  await sandbox.runCommand({
696
729
  cmd: command.cmd,
697
730
  args: command.args,
@@ -713,6 +746,10 @@ function runChat(input) {
713
746
  stderr: new Writable({
714
747
  write(chunk, _encoding, callback) {
715
748
  const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
749
+ console.error("[chat-run] sandbox stderr", {
750
+ sandboxId: sandbox.sandboxId,
751
+ content: text
752
+ });
716
753
  enqueueEvent({ type: "stderr", content: text });
717
754
  callback();
718
755
  }
@@ -969,8 +1006,12 @@ function injectRelayUrl(agent, relayUrl) {
969
1006
  }
970
1007
  };
971
1008
  }
1009
+ function usesBrowserTool(agent) {
1010
+ return isCreateAgentOptions2(agent) && agent.tools?.browser !== void 0;
1011
+ }
972
1012
  async function runCloudChat(input) {
973
- const agentParam = injectRelayUrl(input.agent, input.relayUrl);
1013
+ const browserToolEnabled = usesBrowserTool(input.agent);
1014
+ const agentParam = browserToolEnabled ? injectRelayUrl(input.agent, input.relayUrl) : input.agent;
974
1015
  const agent = resolveAgent(agentParam);
975
1016
  const now = input.now?.() ?? Date.now();
976
1017
  const createRelaySub = input.createRelayRequestSubscription ?? createRelayRequestSubscription;
@@ -992,23 +1033,29 @@ async function runCloudChat(input) {
992
1033
  sendResponse
993
1034
  });
994
1035
  }
995
- const relaySession = await input.createRelaySession();
996
- const relaySubscription = await createRelaySub({
997
- sessionId: relaySession.sessionId,
998
- token: relaySession.token
999
- });
1000
- console.info("[cloud-chat] relay subscription ready", {
1001
- chatId: input.chatId,
1002
- relaySessionId: relaySession.sessionId
1003
- });
1004
1036
  const runtimeInput = {
1005
1037
  ...input.request,
1006
1038
  ...existing?.agentSessionId ? { session_id: existing.agentSessionId } : {},
1007
1039
  ...existing?.sandboxId ? { sandbox_id: existing.sandboxId } : {},
1008
- ...existing?.snapshotId ? { snapshot_id: existing.snapshotId } : {},
1009
- relay_session_id: relaySession.sessionId,
1010
- relay_token: relaySession.token
1040
+ ...existing?.snapshotId ? { snapshot_id: existing.snapshotId } : {}
1011
1041
  };
1042
+ let relaySession;
1043
+ let relaySubscription = null;
1044
+ if (browserToolEnabled) {
1045
+ relaySession = await input.createRelaySession();
1046
+ relaySubscription = await createRelaySub({
1047
+ sessionId: relaySession.sessionId,
1048
+ token: relaySession.token
1049
+ });
1050
+ console.info("[cloud-chat] relay subscription ready", {
1051
+ chatId: input.chatId,
1052
+ relaySessionId: relaySession.sessionId
1053
+ });
1054
+ Object.assign(runtimeInput, {
1055
+ relay_session_id: relaySession.sessionId,
1056
+ relay_token: relaySession.token
1057
+ });
1058
+ }
1012
1059
  let response;
1013
1060
  try {
1014
1061
  response = await (input.runChatImpl ?? runChat)({
@@ -1017,7 +1064,7 @@ async function runCloudChat(input) {
1017
1064
  input: runtimeInput
1018
1065
  });
1019
1066
  } catch (error) {
1020
- await relaySubscription.close().catch(() => void 0);
1067
+ await relaySubscription?.close().catch(() => void 0);
1021
1068
  throw error;
1022
1069
  }
1023
1070
  const managed = createManagedCloudResponseFromReader({
@@ -1032,7 +1079,7 @@ async function runCloudChat(input) {
1032
1079
  relaySubscription,
1033
1080
  relaySession,
1034
1081
  relayUrl: input.relayUrl,
1035
- includeRelaySessionPrelude: true,
1082
+ includeRelaySessionPrelude: browserToolEnabled,
1036
1083
  initialBuffer: "",
1037
1084
  initialTextBlockOpen: false
1038
1085
  });
@@ -1,3 +1,10 @@
1
+ /** Minimal interface for a json-render catalog. */
2
+ type UICatalog = {
3
+ prompt(options?: {
4
+ mode?: "inline" | "standalone";
5
+ customRules?: string[];
6
+ }): string;
7
+ };
1
8
  type AgentFile = {
2
9
  path: string;
3
10
  content: string;
@@ -11,8 +18,10 @@ type AgentConfig = {
11
18
  agentType?: "gemini" | "codex";
12
19
  /** Content for AGENTS.md in the sandbox. */
13
20
  agentMd?: string;
21
+ /** Optional json-render catalog for generative UI. */
22
+ catalog?: UICatalog;
14
23
  /** Environment variables passed to the sandbox at build and run time. */
15
- env?: Record<string, string>;
24
+ env?: Record<string, string | undefined>;
16
25
  /** Additional files to write into the sandbox. */
17
26
  files?: AgentFile[];
18
27
  /** Setup configuration for the sandbox build phase. */
@@ -21,6 +30,7 @@ type AgentConfig = {
21
30
  type DefinedAgent = {
22
31
  readonly agentType: "gemini" | "codex";
23
32
  readonly agentMd?: string;
33
+ readonly catalog?: UICatalog;
24
34
  readonly files: AgentFile[];
25
35
  /** Setup configuration. Undefined when no setup is configured. */
26
36
  readonly setup?: AgentSetup;
@@ -30,4 +40,4 @@ type DefinedAgent = {
30
40
  readonly snapshotId: string;
31
41
  };
32
42
 
33
- export type { AgentConfig as A, DefinedAgent as D, AgentFile as a, AgentSetup as b };
43
+ export type { AgentConfig as A, DefinedAgent as D, UICatalog as U, AgentFile as a, AgentSetup as b };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giselles-ai/agent",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,8 @@
37
37
  "format": "pnpm exec biome check --write ."
38
38
  },
39
39
  "dependencies": {
40
- "@giselles-ai/browser-tool": "0.1.25",
40
+ "@giselles-ai/browser-tool": "0.1.26",
41
+ "@json-render/core": "0.13.0",
41
42
  "@vercel/sandbox": "1.8.1",
42
43
  "@iarna/toml": "3.0.0",
43
44
  "zod": "4.3.6"