|
7793 | 7793 | { |
7794 | 7794 | "name": "getInterrupt", |
7795 | 7795 | "kind": "function", |
7796 | | - "description": "", |
| 7796 | + "description": "Read the agent's current human-in-the-loop interrupt, if any.", |
7797 | 7797 | "signature": "getInterrupt(agent: Agent<>): AgentInterrupt | undefined", |
7798 | 7798 | "params": [ |
7799 | 7799 | { |
7800 | 7800 | "name": "agent", |
7801 | 7801 | "type": "Agent<>", |
7802 | | - "description": "", |
| 7802 | + "description": "The agent to inspect.", |
7803 | 7803 | "optional": false |
7804 | 7804 | } |
7805 | 7805 | ], |
7806 | 7806 | "returns": { |
7807 | 7807 | "type": "AgentInterrupt | undefined", |
7808 | 7808 | "description": "" |
7809 | 7809 | }, |
7810 | | - "examples": [] |
| 7810 | + "examples": [ |
| 7811 | + "```ts\nconst interrupt = getInterrupt(agent);\nif (interrupt) agent.resume('approved');\n```" |
| 7812 | + ] |
7811 | 7813 | }, |
7812 | 7814 | { |
7813 | 7815 | "name": "getMessageType", |
|
7871 | 7873 | { |
7872 | 7874 | "name": "isAssistantMessage", |
7873 | 7875 | "kind": "function", |
7874 | | - "description": "", |
| 7876 | + "description": "Type guard narrowing a Message to `role: 'assistant'`.", |
7875 | 7877 | "signature": "isAssistantMessage(m: Message): m is Message & { role: \"assistant\" }", |
7876 | 7878 | "params": [ |
7877 | 7879 | { |
7878 | 7880 | "name": "m", |
7879 | 7881 | "type": "Message", |
7880 | | - "description": "", |
| 7882 | + "description": "The message to test.", |
7881 | 7883 | "optional": false |
7882 | 7884 | } |
7883 | 7885 | ], |
7884 | 7886 | "returns": { |
7885 | 7887 | "type": "m is Message & { role: \"assistant\" }", |
7886 | 7888 | "description": "" |
7887 | 7889 | }, |
7888 | | - "examples": [] |
| 7890 | + "examples": [ |
| 7891 | + "```ts\nconst reply = agent.messages().findLast(isAssistantMessage);\n```" |
| 7892 | + ] |
7889 | 7893 | }, |
7890 | 7894 | { |
7891 | 7895 | "name": "isSystemMessage", |
7892 | 7896 | "kind": "function", |
7893 | | - "description": "", |
| 7897 | + "description": "Type guard narrowing a Message to `role: 'system'`.", |
7894 | 7898 | "signature": "isSystemMessage(m: Message): m is Message & { role: \"system\" }", |
7895 | 7899 | "params": [ |
7896 | 7900 | { |
7897 | 7901 | "name": "m", |
7898 | 7902 | "type": "Message", |
7899 | | - "description": "", |
| 7903 | + "description": "The message to test.", |
7900 | 7904 | "optional": false |
7901 | 7905 | } |
7902 | 7906 | ], |
7903 | 7907 | "returns": { |
7904 | 7908 | "type": "m is Message & { role: \"system\" }", |
7905 | 7909 | "description": "" |
7906 | 7910 | }, |
7907 | | - "examples": [] |
| 7911 | + "examples": [ |
| 7912 | + "```ts\nconst visible = agent.messages().filter((m) => !isSystemMessage(m));\n```" |
| 7913 | + ] |
7908 | 7914 | }, |
7909 | 7915 | { |
7910 | 7916 | "name": "isToolMessage", |
7911 | 7917 | "kind": "function", |
7912 | | - "description": "", |
| 7918 | + "description": "Type guard narrowing a Message to `role: 'tool'` (a tool result turn).", |
7913 | 7919 | "signature": "isToolMessage(m: Message): m is Message & { role: \"tool\" }", |
7914 | 7920 | "params": [ |
7915 | 7921 | { |
7916 | 7922 | "name": "m", |
7917 | 7923 | "type": "Message", |
7918 | | - "description": "", |
| 7924 | + "description": "The message to test.", |
7919 | 7925 | "optional": false |
7920 | 7926 | } |
7921 | 7927 | ], |
7922 | 7928 | "returns": { |
7923 | 7929 | "type": "m is Message & { role: \"tool\" }", |
7924 | 7930 | "description": "" |
7925 | 7931 | }, |
7926 | | - "examples": [] |
| 7932 | + "examples": [ |
| 7933 | + "```ts\nif (isToolMessage(m)) console.log(m.toolCallId);\n```" |
| 7934 | + ] |
7927 | 7935 | }, |
7928 | 7936 | { |
7929 | 7937 | "name": "isTyping", |
7930 | 7938 | "kind": "function", |
7931 | | - "description": "", |
| 7939 | + "description": "Whether the agent should show a \"typing\" indicator — it is loading and has\nnot yet started streaming the assistant's reply.", |
7932 | 7940 | "signature": "isTyping(agent: Agent<>): boolean", |
7933 | 7941 | "params": [ |
7934 | 7942 | { |
7935 | 7943 | "name": "agent", |
7936 | 7944 | "type": "Agent<>", |
7937 | | - "description": "", |
| 7945 | + "description": "The agent to inspect.", |
7938 | 7946 | "optional": false |
7939 | 7947 | } |
7940 | 7948 | ], |
7941 | 7949 | "returns": { |
7942 | 7950 | "type": "boolean", |
7943 | 7951 | "description": "" |
7944 | 7952 | }, |
7945 | | - "examples": [] |
| 7953 | + "examples": [ |
| 7954 | + "```ts\n\\@if (isTyping(agent)) { <chat-typing-indicator [agent]=\"agent\" /> }\n```" |
| 7955 | + ] |
7946 | 7956 | }, |
7947 | 7957 | { |
7948 | 7958 | "name": "isUserMessage", |
7949 | 7959 | "kind": "function", |
7950 | | - "description": "", |
| 7960 | + "description": "Type guard narrowing a Message to `role: 'user'`.", |
7951 | 7961 | "signature": "isUserMessage(m: Message): m is Message & { role: \"user\" }", |
7952 | 7962 | "params": [ |
7953 | 7963 | { |
7954 | 7964 | "name": "m", |
7955 | 7965 | "type": "Message", |
7956 | | - "description": "", |
| 7966 | + "description": "The message to test.", |
7957 | 7967 | "optional": false |
7958 | 7968 | } |
7959 | 7969 | ], |
7960 | 7970 | "returns": { |
7961 | 7971 | "type": "m is Message & { role: \"user\" }", |
7962 | 7972 | "description": "" |
7963 | 7973 | }, |
7964 | | - "examples": [] |
| 7974 | + "examples": [ |
| 7975 | + "```ts\nconst userTurns = agent.messages().filter(isUserMessage);\n```" |
| 7976 | + ] |
7965 | 7977 | }, |
7966 | 7978 | { |
7967 | 7979 | "name": "messageContent", |
|
7985 | 7997 | { |
7986 | 7998 | "name": "mockAgent", |
7987 | 7999 | "kind": "function", |
7988 | | - "description": "", |
| 8000 | + "description": "Build an in-memory Agent for tests and stories — no transport, no\nnetwork. Every field is a writable signal so a test can drive UI states\n(loading, error, interrupts, tool calls, subagents) deterministically.", |
7989 | 8001 | "signature": "mockAgent(opts: MockAgentOptions): MockAgent<>", |
7990 | 8002 | "params": [ |
7991 | 8003 | { |
7992 | 8004 | "name": "opts", |
7993 | 8005 | "type": "MockAgentOptions", |
7994 | | - "description": "", |
| 8006 | + "description": "Initial values for the mock's signals; all optional.", |
7995 | 8007 | "optional": true |
7996 | 8008 | } |
7997 | 8009 | ], |
7998 | 8010 | "returns": { |
7999 | 8011 | "type": "MockAgent<>", |
8000 | 8012 | "description": "" |
8001 | 8013 | }, |
8002 | | - "examples": [] |
| 8014 | + "examples": [ |
| 8015 | + "```ts\nconst agent = mockAgent({\n messages: [{ id: '1', role: 'assistant', content: 'Hi' }],\n isLoading: true,\n});\n```" |
| 8016 | + ] |
8003 | 8017 | }, |
8004 | 8018 | { |
8005 | 8019 | "name": "normalizeEnvelopeArgs", |
|
0 commit comments