genaicode 2.31.0 → 2.33.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.
- package/README.md +1 -0
- package/dist/agents/artifacts.d.ts +16 -6
- package/dist/agents/artifacts.js +74 -23
- package/dist/agents/artifacts.js.map +1 -1
- package/dist/agents/handoff.d.ts +14 -3
- package/dist/agents/handoff.js +55 -5
- package/dist/agents/handoff.js.map +1 -1
- package/dist/agents/session.d.ts +11 -0
- package/dist/agents/session.js +22 -5
- package/dist/agents/session.js.map +1 -1
- package/dist/agents/types.d.ts +2 -2
- package/dist/agents.d.ts +1 -1
- package/dist/app-agent/http.js +2 -2
- package/dist/app-agent/http.js.map +1 -1
- package/dist/browser/fake-model.d.ts +43 -0
- package/dist/browser/fake-model.js +133 -0
- package/dist/browser/fake-model.js.map +1 -0
- package/dist/browser/language-model.d.ts +74 -0
- package/dist/browser/language-model.js +83 -0
- package/dist/browser/language-model.js.map +1 -0
- package/dist/browser/nano.d.ts +83 -0
- package/dist/browser/nano.js +610 -0
- package/dist/browser/nano.js.map +1 -0
- package/dist/browser/page-agent.d.ts +74 -0
- package/dist/browser/page-agent.js +339 -0
- package/dist/browser/page-agent.js.map +1 -0
- package/dist/browser/tools.d.ts +36 -0
- package/dist/browser/tools.js +190 -0
- package/dist/browser/tools.js.map +1 -0
- package/dist/browser/webmcp.d.ts +32 -0
- package/dist/browser/webmcp.js +150 -0
- package/dist/browser/webmcp.js.map +1 -0
- package/dist/browser.d.ts +39 -0
- package/dist/browser.js +32 -0
- package/dist/browser.js.map +1 -0
- package/dist/react/agent-chat.css +174 -0
- package/dist/react/agent-chat.d.ts +23 -2
- package/dist/react/agent-chat.js +114 -13
- package/dist/react/agent-chat.js.map +1 -1
- package/dist/react/app-agent-chat.d.ts +2 -0
- package/dist/react/app-agent-chat.js +1 -1
- package/dist/react/app-agent-chat.js.map +1 -1
- package/dist/react/attachments.d.ts +41 -0
- package/dist/react/attachments.js +162 -0
- package/dist/react/attachments.js.map +1 -0
- package/dist/react/page-agent-chat.d.ts +38 -0
- package/dist/react/page-agent-chat.js +40 -0
- package/dist/react/page-agent-chat.js.map +1 -0
- package/dist/react.d.ts +7 -2
- package/dist/react.js +3 -1
- package/dist/react.js.map +1 -1
- package/dist/ui/index.js +82 -78
- package/dist/ui/web-client.js +187 -12
- package/docs/agents.md +26 -4
- package/docs/browser.md +200 -0
- package/docs/react.md +14 -13
- package/docs/semver.md +2 -0
- package/package.json +5 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { AgentRun, AgentTask, CodingAgent } from '../agents/types.js';
|
|
2
|
+
import { type LanguageModelAvailability, type LanguageModelFactory, type LanguageModelMedia } from './language-model.js';
|
|
3
|
+
import { type PageTool } from './tools.js';
|
|
4
|
+
export interface NanoOptions {
|
|
5
|
+
/** What the model may do on the page. A function is called at the start of every task. */
|
|
6
|
+
tools?: readonly PageTool[] | (() => readonly PageTool[] | Promise<readonly PageTool[]>);
|
|
7
|
+
/** Who the assistant is and what the page is about. Keep it short: the context window is small. */
|
|
8
|
+
instructions?: string;
|
|
9
|
+
/** Language of the conversation (the Prompt API supports a few). Default `en`. */
|
|
10
|
+
language?: string;
|
|
11
|
+
/** Most tool calls in one task before the model has to answer. Default 6. */
|
|
12
|
+
maxSteps?: number;
|
|
13
|
+
/** Longest tool output the model is shown, in characters. Default 2,000. */
|
|
14
|
+
maxToolOutput?: number;
|
|
15
|
+
/** Shown as the model's name. Default `on-device`. */
|
|
16
|
+
model?: string;
|
|
17
|
+
/** Agent name. Default `nano`. */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** The Prompt API to use. Default: the browser's `LanguageModel`. */
|
|
20
|
+
languageModel?: LanguageModelFactory;
|
|
21
|
+
/**
|
|
22
|
+
* What a task may attach besides text files: images, audio (a voice message). Asked of the
|
|
23
|
+
* browser's model, which may take neither; `inputs()` says what it does take. Default: none.
|
|
24
|
+
*/
|
|
25
|
+
inputs?: readonly LanguageModelMedia[];
|
|
26
|
+
/** Longest text of one attached file the model is shown, in characters. Default 4,000. */
|
|
27
|
+
maxAttachmentText?: number;
|
|
28
|
+
/** Download progress of the model, 0 to 1, while a task or `prepare()` waits for it. */
|
|
29
|
+
onDownload?(progress: number): void;
|
|
30
|
+
/** Called after every call to the model, with how long it took: for logs and tuning. */
|
|
31
|
+
onModelCall?(call: NanoModelCall): void;
|
|
32
|
+
}
|
|
33
|
+
/** One call to the model within a task. */
|
|
34
|
+
export interface NanoModelCall {
|
|
35
|
+
/** `choose`: tool or reply. `arguments`: the tool's arguments. `reply`: the answer. */
|
|
36
|
+
step: 'choose' | 'arguments' | 'reply';
|
|
37
|
+
ms: number;
|
|
38
|
+
/** Whether the browser held the answer to a JSON Schema. */
|
|
39
|
+
constrained: boolean;
|
|
40
|
+
/** Why the call failed. */
|
|
41
|
+
error?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A task for `nano()`: an `AgentTask` that may carry files. A text file is read into the prompt,
|
|
45
|
+
* an image or audio goes to the model as it is (`NanoOptions.inputs`). A `File` keeps its name.
|
|
46
|
+
*/
|
|
47
|
+
export interface NanoTask extends AgentTask {
|
|
48
|
+
attachments?: readonly Blob[];
|
|
49
|
+
}
|
|
50
|
+
/** A `CodingAgent` that runs in the page, on the browser's built-in model. */
|
|
51
|
+
export interface NanoAgent extends CodingAgent {
|
|
52
|
+
run(task: NanoTask): AgentRun;
|
|
53
|
+
/** Which of `NanoOptions.inputs` this browser's model takes. Empty where it takes text only. */
|
|
54
|
+
inputs(): Promise<LanguageModelMedia[]>;
|
|
55
|
+
/** Whether the browser has the model, could download it, or cannot run it at all. */
|
|
56
|
+
availability(): Promise<LanguageModelAvailability>;
|
|
57
|
+
/**
|
|
58
|
+
* Load the model now, downloading it first when needed (several GB, once per browser), so the
|
|
59
|
+
* first task does not wait. A download needs a user gesture: call this from a click.
|
|
60
|
+
*/
|
|
61
|
+
prepare(signal?: AbortSignal): Promise<void>;
|
|
62
|
+
/** Tokens in use and the size of a conversation's context window, where the browser says. */
|
|
63
|
+
context(sessionId: string): {
|
|
64
|
+
used: number;
|
|
65
|
+
window: number;
|
|
66
|
+
} | undefined;
|
|
67
|
+
/** Drop a conversation (`sessionId` of a result), or all of them, and free the model's memory. */
|
|
68
|
+
forget(sessionId?: string): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The browser's built-in model (Gemini Nano through Chrome's Prompt API) as a genaicode agent.
|
|
72
|
+
* It runs in the page, costs nothing and sends nothing to a server; it is a small model, good
|
|
73
|
+
* for one or two tool calls and a short answer, not for coding.
|
|
74
|
+
*
|
|
75
|
+
* The Prompt API has no tool calling, so each step is a constrained choice: the model picks a
|
|
76
|
+
* tool or `reply`, then fills in that tool's arguments against its JSON Schema, and the final
|
|
77
|
+
* answer streams as text. `write` tools go through `task.onApproval` first, and never run under
|
|
78
|
+
* `permissions.sandbox: 'read-only'`; other sandbox values fail the task, as a page has none. `task.resume`
|
|
79
|
+
* continues a conversation; `task.cwd`, `env` and `mcpServers` mean nothing here.
|
|
80
|
+
*/
|
|
81
|
+
export declare function nano(options?: NanoOptions): NanoAgent;
|
|
82
|
+
/** What the model is told once, as the system prompt. */
|
|
83
|
+
export declare function briefing(instructions: string | undefined, tools: readonly PageTool[]): string;
|