@theoremjs/studio 0.3.4-next.717.gd16ffc6 → 0.3.4-next.723.g003a589
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/browser-execution.d.ts +3 -2
- package/browser-execution.js +2 -0
- package/browser-live.js +1 -0
- package/browser-transport.js +1 -0
- package/package.json +4 -4
- package/page/assets/{Banner-taynF7yD.js → Banner-CXgn2jQ5.js} +2 -2
- package/page/assets/{ConsoleFrame-Bt1u0rP3.js → ConsoleFrame-DL-E3d17.js} +1 -1
- package/page/assets/{MenuBottomSheet-qwqUlpTu.js → MenuBottomSheet-Dzp39CFk.js} +1 -1
- package/page/assets/{SchemaFields-CATpYH7H.js → SchemaFields-CaSEjUFp.js} +1 -1
- package/page/assets/{ToolResultCharts-36u9-VXv.js → ToolResultCharts-CzyLZHN1.js} +1 -1
- package/page/assets/{TraceInspector-DD9j4npn.js → TraceInspector-BYwL8LMO.js} +1 -1
- package/page/assets/{TraceOverview-DNyvzn4n.js → TraceOverview-BZm_Oc0q.js} +1 -1
- package/page/assets/{_virtual_studio-type-sources-0wBr_OTt.js → _virtual_studio-type-sources-BSY0b1_W.js} +3 -1
- package/page/assets/browser-engine-Bdj8kmu5.js +13 -0
- package/page/assets/{browser-transport-DLq9keGR.js → browser-transport-B06rbnhT.js} +3 -3
- package/page/assets/{export-agent-B0Xmvx1B.js → export-agent-DRq_nP7v.js} +1 -1
- package/page/assets/{guardrail-tester-CaHB3cVd.js → guardrail-tester-BTIGo6fQ.js} +1 -1
- package/page/assets/index-dW2qr0Li.js +149 -0
- package/page/assets/{studio-code-pane-BLk45U5u.js → studio-code-pane-6eLLRIXD.js} +3 -3
- package/page/assets/{studio-console-DCX8azjt.js → studio-console-D8YgbJO9.js} +1 -1
- package/page/assets/{studio-decision-d20tk3cf.js → studio-decision-qX_0Rr1j.js} +1 -1
- package/page/assets/{studio-embedding-tG47CRXO.js → studio-embedding-AQyq3Iul.js} +1 -1
- package/page/assets/{studio-host-console-BPlQhfit.js → studio-host-console-DZqaklI1.js} +2 -2
- package/page/assets/{studio-labels-BZL94cUv.js → studio-labels-DQT-TCZY.js} +1 -1
- package/page/assets/{studio-live-F8Y_By_i.js → studio-live-BrPi5qNt.js} +2 -2
- package/page/assets/{studio-map-B6nuVNPy.js → studio-map-B5afZy1C.js} +1 -1
- package/page/assets/{studio-trace-replay-5L0DOE0z.js → studio-trace-replay-BZ29fvuZ.js} +2 -2
- package/page/assets/{studio-type-checker-DSSsgtvc.js → studio-type-checker-BO-lN_65.js} +1 -1
- package/page/assets/{use-one-call-C-E3OiCG.js → use-one-call-BbOooVbP.js} +1 -1
- package/page/index.html +4 -4
- package/replay.js +1 -0
- package/runtime-scope.d.ts +10 -1
- package/runtime-scope.js +7 -0
- package/runtime.js +3 -0
- package/server/handler.js +2 -1
- package/server/live.js +2 -0
- package/ui/profile-editor.js +32 -2
- package/page/assets/browser-engine-CMh-qsyo.js +0 -13
- package/page/assets/index-CZ-4laVO.js +0 -149
package/replay.js
CHANGED
package/runtime-scope.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Studio drafts, each run on a kernel scope of its own. Two visitors can
|
|
3
3
|
* name the same profile, tool, or schema without either one seeing the other's.
|
|
4
4
|
*/
|
|
5
|
-
import { defineProfile, type KernelScope, type Profile, type ProfileDefinition, type Provider, type RegisteredProvider, type ResolveHost, type ToolExecutionCoordinator } from '@theoremjs/agents';
|
|
5
|
+
import { defineProfile, type KernelScope, type Profile, type ProfileDefinition, type Provider, type RegisteredProvider, type ResolveHost, type ToolBackgroundService, type ToolExecutionCoordinator } from '@theoremjs/agents';
|
|
6
6
|
import { type DetectSpec } from '@theoremjs/agents/guardrails';
|
|
7
7
|
import type { AgentCall, AgentCallHook, ProviderHostOptions, TurnModel } from '@theoremjs/agents/kernel';
|
|
8
8
|
export interface StudioProviderOptions extends ProviderHostOptions {
|
|
@@ -14,12 +14,21 @@ export interface StudioProviderOptions extends ProviderHostOptions {
|
|
|
14
14
|
import { type StudioRunsOn } from './lent-keys.ts';
|
|
15
15
|
import type { StructuredRegistration, ToolRegistration } from './registrations.ts';
|
|
16
16
|
import { type StudioToolHandlers } from './tools.ts';
|
|
17
|
+
/**
|
|
18
|
+
* A detached call's service for a run whose session lives as long as the work does: the studio's
|
|
19
|
+
* own server, or the page's tab.
|
|
20
|
+
* why: the session keeps each call's state and end, and a conversation read shows them, so a late
|
|
21
|
+
* event has nowhere else to go.
|
|
22
|
+
*/
|
|
23
|
+
export declare const STUDIO_BACKGROUND: ToolBackgroundService;
|
|
17
24
|
/** What a run holds besides what it runs on. */
|
|
18
25
|
export interface StudioRuntimeBase {
|
|
19
26
|
/** A project's own provider definitions, registered after the studio's. */
|
|
20
27
|
providerDefinitions?: readonly Provider[];
|
|
21
28
|
execution?: ToolExecutionCoordinator;
|
|
22
29
|
pageExecution?: import('@theoremjs/agents').PageToolExecution;
|
|
30
|
+
/** Without it every tool runs inline, whatever its `background` setting. */
|
|
31
|
+
background?: ToolBackgroundService;
|
|
23
32
|
providers?: StudioProviderOptions;
|
|
24
33
|
hostOptions?: (profile: Profile, model?: string) => ProviderHostOptions;
|
|
25
34
|
/** Answers every model call with a scripted model, in place of the profile's provider. */
|
package/runtime-scope.js
CHANGED
|
@@ -11,6 +11,13 @@ import { lentCompression, runtimeNetwork } from "./lent-keys.js";
|
|
|
11
11
|
import { modelBindingViolation } from "./policy.js";
|
|
12
12
|
import { localProviderAddress, registerStudioProvider, STUDIO_PROVIDERS } from "./providers.js";
|
|
13
13
|
import { registerDefined } from "./tools.js";
|
|
14
|
+
/**
|
|
15
|
+
* A detached call's service for a run whose session lives as long as the work does: the studio's
|
|
16
|
+
* own server, or the page's tab.
|
|
17
|
+
* why: the session keeps each call's state and end, and a conversation read shows them, so a late
|
|
18
|
+
* event has nowhere else to go.
|
|
19
|
+
*/
|
|
20
|
+
export const STUDIO_BACKGROUND = { detached() { }, event() { } };
|
|
14
21
|
/** The protocol event a scripted model's event stands for. */
|
|
15
22
|
function protocolEvent(event) {
|
|
16
23
|
if (event.type === 'tool')
|
package/runtime.js
CHANGED
|
@@ -66,6 +66,7 @@ function studioRunner(args) {
|
|
|
66
66
|
profile: profile.id,
|
|
67
67
|
execution: runtime.execution,
|
|
68
68
|
pageExecution: runtime.pageExecution,
|
|
69
|
+
background: runtime.background,
|
|
69
70
|
metadata,
|
|
70
71
|
input: turn.input,
|
|
71
72
|
...turn.stated,
|
|
@@ -234,6 +235,7 @@ function answerReplayed(scope, profile, request, replay, runtime) {
|
|
|
234
235
|
resolveHost: runtime.resolveHost,
|
|
235
236
|
execution: runtime.execution,
|
|
236
237
|
pageExecution: runtime.pageExecution,
|
|
238
|
+
background: runtime.background,
|
|
237
239
|
onAgentCall: agentCallHook(scope, runtime),
|
|
238
240
|
};
|
|
239
241
|
}
|
|
@@ -338,6 +340,7 @@ export async function* streamStudioCall(args) {
|
|
|
338
340
|
profile: profile.id,
|
|
339
341
|
execution: args.runtime.execution,
|
|
340
342
|
pageExecution: args.runtime.pageExecution,
|
|
343
|
+
background: args.runtime.background,
|
|
341
344
|
name: args.call.name,
|
|
342
345
|
input: args.call.input,
|
|
343
346
|
sessionPermissions: args.sessionPermissions,
|
package/server/handler.js
CHANGED
|
@@ -26,7 +26,7 @@ import { STUDIO_TRACE_DESTINATION } from "../policy.js";
|
|
|
26
26
|
import { kernelDefinition, modelSlots, registerStudioProvider, } from "../providers.js";
|
|
27
27
|
import { readStudioSource } from "../read-source.js";
|
|
28
28
|
import { STUDIO_READER } from "../reader.js";
|
|
29
|
-
import { withPatterns } from "../runtime-scope.js";
|
|
29
|
+
import { STUDIO_BACKGROUND, withPatterns } from "../runtime-scope.js";
|
|
30
30
|
import { studioSource } from "../source.js";
|
|
31
31
|
import { createStudioDraftHandler, STUDIO_BASE } from "./draft-handler.js";
|
|
32
32
|
import { errorJson } from "./draft-replies.js";
|
|
@@ -525,6 +525,7 @@ function profileHandlers(options, problems) {
|
|
|
525
525
|
...(isStateless ? {} : { conversationStore: chatStore() }),
|
|
526
526
|
// The studio's page is the builder's own: its picks choose the prompt lines.
|
|
527
527
|
pageStatesTurn: true,
|
|
528
|
+
background: () => STUDIO_BACKGROUND,
|
|
528
529
|
...shared,
|
|
529
530
|
});
|
|
530
531
|
served.set(profile.id, withRunTraces(isStateless ? chat : startsConversations(chat, profile, chatStore(), shared.session)));
|
package/server/live.js
CHANGED
|
@@ -10,6 +10,7 @@ import { clientError } from '@theoremjs/agents/host';
|
|
|
10
10
|
import { createMemorySessionStore, createTheoremSessionBoundary, parseLiveOpenMessage, } from '@theoremjs/web/server';
|
|
11
11
|
import { attachStudioLiveSession } from "../live-session-bridge.js";
|
|
12
12
|
import { STUDIO_READER } from "../reader.js";
|
|
13
|
+
import { STUDIO_BACKGROUND } from "../runtime-scope.js";
|
|
13
14
|
/** The call's records reach the page through its own sink, so the bridge has no route to close. */
|
|
14
15
|
const NO_ROUTE = { metadata: {}, close: () => { } };
|
|
15
16
|
/**
|
|
@@ -61,6 +62,7 @@ async function relay(socket, profile, provider, boundary, { host }) {
|
|
|
61
62
|
profile: profile.id,
|
|
62
63
|
execution: boundary.toolExecution,
|
|
63
64
|
pageExecution: boundary.pageExecution,
|
|
65
|
+
background: STUDIO_BACKGROUND,
|
|
64
66
|
...(host === undefined ? {} : { host }),
|
|
65
67
|
}, provider, pageSink(socket, profile));
|
|
66
68
|
}
|
package/ui/profile-editor.js
CHANGED
|
@@ -23,7 +23,7 @@ import { Thumbnail } from '@astryxdesign/core/Thumbnail';
|
|
|
23
23
|
import { Token } from '@astryxdesign/core/Token';
|
|
24
24
|
import { Tooltip } from '@astryxdesign/core/Tooltip';
|
|
25
25
|
import { VStack } from '@astryxdesign/core/VStack';
|
|
26
|
-
import { IconAbc, IconAdjustmentsHorizontal, IconAlertTriangle, IconAlignLeft, IconAntennaBars1, IconAntennaBars2, IconAntennaBars3, IconAntennaBars4, IconAntennaBars5, IconAntennaBarsOff, IconArrowDown, IconArrowLeft, IconArrowUp, IconBan, IconBandage, IconBiohazard, IconBolt, IconBraces, IconBulb, IconBulbOff, IconCertificate, IconCheck, IconChevronRight, IconCircleDashed, IconDatabase, IconDeviceDesktop, IconEraser, IconEye, IconEyeOff, IconFeather, IconFlag, IconFlame, IconFlask, IconFold, IconGauge, IconHandOff, IconHandStop, IconHeadset, IconHourglass, IconHttpDelete, IconHttpGet, IconHttpPatch, IconHttpPost, IconHttpPut, IconInfoCircle, IconInputAi, IconKey, IconLayersUnion, IconLockOpen, IconLogin, IconMessage, IconMicrophone, IconPackage, IconPaperclip, IconPencil, IconPlayerPause, IconPlayerPlay, IconPlayerStop, IconPlayerTrackNext, IconPlugConnected, IconPlus, IconRefresh, IconRegex, IconRuler, IconSearch, IconSend, IconServer, IconShieldLock, IconShieldOff, IconShieldSearch, IconSquareRoundedNumber0, IconSquareRoundedNumber2, IconTool, IconTrash, IconUser, IconUserCheck, IconWaveSine, IconWriting, IconX, } from '@tabler/icons-react';
|
|
26
|
+
import { IconAbc, IconAdjustmentsHorizontal, IconAlertTriangle, IconAlignLeft, IconAntennaBars1, IconAntennaBars2, IconAntennaBars3, IconAntennaBars4, IconAntennaBars5, IconAntennaBarsOff, IconArrowDown, IconArrowLeft, IconArrowUp, IconBan, IconBandage, IconBiohazard, IconBolt, IconBraces, IconBulb, IconBulbOff, IconCertificate, IconCheck, IconChevronRight, IconCircleDashed, IconClock, IconDatabase, IconDeviceDesktop, IconEraser, IconEye, IconEyeOff, IconFeather, IconFlag, IconFlame, IconFlask, IconFold, IconGauge, IconHandOff, IconHandStop, IconHeadset, IconHourglass, IconHttpDelete, IconHttpGet, IconHttpPatch, IconHttpPost, IconHttpPut, IconInfoCircle, IconInputAi, IconKey, IconLayersUnion, IconLockOpen, IconLogin, IconMessage, IconMessageQuestion, IconMicrophone, IconPackage, IconPaperclip, IconPencil, IconPlayerPause, IconPlayerPlay, IconPlayerStop, IconPlayerTrackNext, IconPlugConnected, IconPlus, IconRefresh, IconRegex, IconRuler, IconSearch, IconSend, IconServer, IconShieldLock, IconShieldOff, IconShieldSearch, IconSquareRoundedNumber0, IconSquareRoundedNumber2, IconTool, IconTrash, IconUser, IconUserCheck, IconWaveSine, IconWriting, IconX, } from '@tabler/icons-react';
|
|
27
27
|
import { ATTACHMENT_ACCEPT_MIMES, CONTINUE_STOP_KINDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, labelDefault, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, profileGraphFacet, SPEECH_AUDIO_FORMATS, THINKING_LEVELS, VOICE_ACCEPT_MIMES, } from '@theoremjs/agents';
|
|
28
28
|
import { BOUNDARIES, BOUNDARY_META, DETECT_ACTION_META, DETECT_ACTIONS, DETECTOR_BOUNDARIES, DETECTOR_GROUP_META, DETECTOR_GROUPS, DETECTOR_META, DETECTORS, TOOL_BOUNDARIES, TOOL_KINDS, } from '@theoremjs/agents/guardrails';
|
|
29
29
|
import { MODEL_SELECT_MIN_MODELS } from '@theoremjs/agents/interface';
|
|
@@ -1864,6 +1864,24 @@ const PERMISSION_SEGMENTS = [
|
|
|
1864
1864
|
{ value: 'session_consent', label: 'Once a session', icon: IconUserCheck },
|
|
1865
1865
|
{ value: 'always_confirm', label: 'Every call', icon: IconHandStop },
|
|
1866
1866
|
];
|
|
1867
|
+
const BACKGROUND_SEGMENTS = [
|
|
1868
|
+
{ value: 'never', label: 'Never', icon: IconPlayerPause },
|
|
1869
|
+
{ value: 'ask', label: 'Model asks', icon: IconMessageQuestion },
|
|
1870
|
+
{ value: 'always', label: 'Always', icon: IconPlayerTrackNext },
|
|
1871
|
+
{ value: 'afterMs', label: 'After a time', icon: IconClock },
|
|
1872
|
+
];
|
|
1873
|
+
/** A newly picked wait, until the builder sets their own. */
|
|
1874
|
+
const BACKGROUND_AFTER_MS = 10_000;
|
|
1875
|
+
function backgroundSegment(background) {
|
|
1876
|
+
if (typeof background === 'object')
|
|
1877
|
+
return 'afterMs';
|
|
1878
|
+
return background ?? 'never';
|
|
1879
|
+
}
|
|
1880
|
+
function backgroundOf(segment, afterMs) {
|
|
1881
|
+
if (segment === 'afterMs')
|
|
1882
|
+
return { afterMs: afterMs ?? BACKGROUND_AFTER_MS };
|
|
1883
|
+
return segment === 'never' ? undefined : segment;
|
|
1884
|
+
}
|
|
1867
1885
|
const METHOD_SEGMENTS = [
|
|
1868
1886
|
{ value: 'GET', label: 'GET', icon: IconHttpGet },
|
|
1869
1887
|
{ value: 'POST', label: 'POST', icon: IconHttpPost },
|
|
@@ -2276,13 +2294,25 @@ function AuthSection({ tool, set }) {
|
|
|
2276
2294
|
set({ authType: next });
|
|
2277
2295
|
} }), authType !== 'none' && _jsx(AuthCredentialRows, { tool: tool, authType: authType, set: set }), authType === 'oauth2' && _jsx(OAuthRows, { tool: tool, set: set })] }));
|
|
2278
2296
|
}
|
|
2297
|
+
/** When the model gets its reply: the setting, and the time for one that waits. */
|
|
2298
|
+
function BackgroundRows({ tool, set }) {
|
|
2299
|
+
const { background } = tool;
|
|
2300
|
+
const afterMs = typeof background === 'object' ? background.afterMs : null;
|
|
2301
|
+
return (_jsxs(_Fragment, { children: [_jsx(SegmentedRow, { label: "Background", path: "registerTool.background", field: "background", value: backgroundSegment(background), segments: BACKGROUND_SEGMENTS, onChange: (segment) => {
|
|
2302
|
+
set({ background: backgroundOf(segment, afterMs) });
|
|
2303
|
+
} }), afterMs === null ? null : (_jsx(NumberRow, { label: "After", path: "registerTool.background.afterMs", field: "background", value: afterMs, min: 0, isIntegerOnly: true, units: "ms", onChange: (next) => {
|
|
2304
|
+
if (next !== null)
|
|
2305
|
+
set({ background: { afterMs: next } });
|
|
2306
|
+
} }))] }));
|
|
2307
|
+
}
|
|
2279
2308
|
/** Who may call the tool, whether it asks first, when it loads and on which paths. */
|
|
2280
2309
|
function PolicySection({ draft, tool, set, }) {
|
|
2310
|
+
const isLoader = draft.tools.t2Loader.trim() === tool.toolName.trim();
|
|
2281
2311
|
return (_jsxs(InspectorSection, { title: "Policy", children: [_jsx(SegmentedRow, { label: "Access", path: "registerTool.access", field: "access", value: tool.access, segments: ACCESS_SEGMENTS, onChange: (access) => {
|
|
2282
2312
|
set({ access });
|
|
2283
2313
|
} }), _jsx(SegmentedRow, { label: "Permission", path: "registerTool.permission", field: "permission", value: tool.permission, segments: PERMISSION_SEGMENTS, onChange: (permission) => {
|
|
2284
2314
|
set({ permission });
|
|
2285
|
-
} }), _jsx(SegmentedRow, { label: "Load tier", path: "registerTool.loadTier", field: "loadTier", value: tool.loadTier, segments: LOAD_TIER_SEGMENTS, warning: loadTierWarning(draft, tool.loadTier), onChange: (loadTier) => {
|
|
2315
|
+
} }), tool.answeredBy === 'page' || isLoader ? null : _jsx(BackgroundRows, { tool: tool, set: set }), _jsx(SegmentedRow, { label: "Load tier", path: "registerTool.loadTier", field: "loadTier", value: tool.loadTier, segments: LOAD_TIER_SEGMENTS, warning: loadTierWarning(draft, tool.loadTier), onChange: (loadTier) => {
|
|
2286
2316
|
set({ loadTier });
|
|
2287
2317
|
} }), _jsx(NamesRow, { label: "Paths", path: "registerTool.paths", field: "paths", value: tool.paths, placeholder: "Every path (*)", onChange: (paths) => {
|
|
2288
2318
|
set({ paths });
|