@norskvideo/norsk-studio-alpha 1.27.0-2026-02-01-68c1474f → 1.27.0-2026-02-02-24ae15e8
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/client/info.js +145 -11
- package/lib/info.js +3 -1
- package/lib/info.js.map +1 -1
- package/lib/util.openaiAgent/_gen/schema.d.ts +17 -0
- package/lib/util.openaiAgent/_gen/schema.js +21 -0
- package/lib/util.openaiAgent/_gen/schema.js.map +1 -0
- package/lib/util.openaiAgent/_gen/types.d.ts +370 -0
- package/lib/util.openaiAgent/_gen/types.js +3 -0
- package/lib/util.openaiAgent/_gen/types.js.map +1 -0
- package/lib/util.openaiAgent/_gen/zod.d.ts +2 -0
- package/lib/util.openaiAgent/_gen/zod.js +147 -0
- package/lib/util.openaiAgent/_gen/zod.js.map +1 -0
- package/lib/util.openaiAgent/info.d.ts +63 -0
- package/lib/util.openaiAgent/info.js +133 -0
- package/lib/util.openaiAgent/info.js.map +1 -0
- package/lib/util.openaiAgent/runtime.d.ts +103 -0
- package/lib/util.openaiAgent/runtime.js +545 -0
- package/lib/util.openaiAgent/runtime.js.map +1 -0
- package/lib/util.openaiAgent/types.yaml +392 -0
- package/package.json +5 -4
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const agent_1 = require("@norskvideo/norsk-studio-built-ins/lib/shared/agent");
|
|
5
|
+
function default_1({ defineComponent, validation: { Z }, }) {
|
|
6
|
+
return defineComponent({
|
|
7
|
+
identifier: 'util.openaiAgent',
|
|
8
|
+
category: 'processor',
|
|
9
|
+
name: "OpenAI Agent",
|
|
10
|
+
description: "An autonomous agent powered by OpenAI that can react to events from other components, execute commands, set timers, and maintain working memory. Uses the OpenAI Agents SDK with built-in agentic loop.",
|
|
11
|
+
subscription: {},
|
|
12
|
+
display: (_desc) => { return {}; },
|
|
13
|
+
runtime: {
|
|
14
|
+
initialState: () => ({
|
|
15
|
+
status: 'idle',
|
|
16
|
+
currentTask: undefined,
|
|
17
|
+
activeTimerCount: 0,
|
|
18
|
+
activeSubscriptionCount: 0,
|
|
19
|
+
invocationCount: 0,
|
|
20
|
+
lastActivity: undefined,
|
|
21
|
+
errorMessage: undefined
|
|
22
|
+
}),
|
|
23
|
+
handleEvent(ev, state) {
|
|
24
|
+
const evType = ev.type;
|
|
25
|
+
switch (evType) {
|
|
26
|
+
case 'agent_invoked':
|
|
27
|
+
state.status = 'thinking';
|
|
28
|
+
state.currentTask = ev.prompt;
|
|
29
|
+
break;
|
|
30
|
+
case 'agent_completed':
|
|
31
|
+
state.status = 'idle';
|
|
32
|
+
state.currentTask = undefined;
|
|
33
|
+
state.invocationCount = (state.invocationCount || 0) + 1;
|
|
34
|
+
state.lastActivity = new Date().toISOString();
|
|
35
|
+
break;
|
|
36
|
+
case 'timer_set':
|
|
37
|
+
state.activeTimerCount = (state.activeTimerCount || 0) + 1;
|
|
38
|
+
break;
|
|
39
|
+
case 'timer_cancelled':
|
|
40
|
+
case 'timer_fired':
|
|
41
|
+
state.activeTimerCount = Math.max(0, (state.activeTimerCount || 0) - 1);
|
|
42
|
+
break;
|
|
43
|
+
case 'subscription_added':
|
|
44
|
+
state.activeSubscriptionCount = (state.activeSubscriptionCount || 0) + 1;
|
|
45
|
+
break;
|
|
46
|
+
case 'subscription_removed':
|
|
47
|
+
state.activeSubscriptionCount = Math.max(0, (state.activeSubscriptionCount || 0) - 1);
|
|
48
|
+
break;
|
|
49
|
+
case 'error_occurred':
|
|
50
|
+
state.status = 'error';
|
|
51
|
+
state.errorMessage = ev.error;
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
assertUnreachable(evType);
|
|
55
|
+
}
|
|
56
|
+
return { ...state };
|
|
57
|
+
},
|
|
58
|
+
summary: agent_1.AgentSummaryView,
|
|
59
|
+
fullscreen: (props) => (0, agent_1.AgentFullscreenView)({ ...props, agentName: "OpenAI Agent" }),
|
|
60
|
+
},
|
|
61
|
+
configForm: {
|
|
62
|
+
form: {
|
|
63
|
+
mission: {
|
|
64
|
+
help: "The agent's ongoing task/goal for this workflow - what should it accomplish?",
|
|
65
|
+
hint: {
|
|
66
|
+
type: 'text',
|
|
67
|
+
validation: Z.string().min(10).max(2000),
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
systemPrompt: {
|
|
71
|
+
help: "Base instruction defining the agent's capabilities and how it should behave",
|
|
72
|
+
hint: {
|
|
73
|
+
type: 'text',
|
|
74
|
+
validation: Z.string().min(10).max(4000),
|
|
75
|
+
defaultValue: `You are an autonomous agent monitoring a video processing workflow.
|
|
76
|
+
|
|
77
|
+
You have tools to:
|
|
78
|
+
- Inspect the current workflow and discover component ids/purpose
|
|
79
|
+
- Set timers for periodic checks or delayed actions
|
|
80
|
+
- Subscribe to events from other components
|
|
81
|
+
- Execute commands on components
|
|
82
|
+
- Store information in working memory
|
|
83
|
+
|
|
84
|
+
When you receive events or timer notifications, evaluate them against your mission and take appropriate action.`
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
model: {
|
|
88
|
+
help: "OpenAI model to use",
|
|
89
|
+
hint: {
|
|
90
|
+
type: 'select',
|
|
91
|
+
options: [
|
|
92
|
+
{ value: 'gpt-4o', display: 'GPT-4o (recommended)' },
|
|
93
|
+
{ value: 'gpt-4o-mini', display: 'GPT-4o Mini (fast)' },
|
|
94
|
+
{ value: 'gpt-4-turbo', display: 'GPT-4 Turbo' },
|
|
95
|
+
{ value: 'o1', display: 'o1 (reasoning)' },
|
|
96
|
+
{ value: 'o3-mini', display: 'o3-mini (reasoning, fast)' },
|
|
97
|
+
],
|
|
98
|
+
defaultValue: 'gpt-4o'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
initialPrompt: {
|
|
102
|
+
help: "Optional message to send when the agent starts (after mission is set)",
|
|
103
|
+
hint: {
|
|
104
|
+
type: 'text',
|
|
105
|
+
optional: true,
|
|
106
|
+
validation: Z.string().max(2000),
|
|
107
|
+
defaultValue: 'Use the tools provided to discover component ids, and set up events and timers as necessary to complete the user mission'
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
maxStepsPerInvocation: {
|
|
111
|
+
help: "Maximum tool calls per agent invocation (default: 20)",
|
|
112
|
+
advanced: true,
|
|
113
|
+
hint: {
|
|
114
|
+
type: 'numeric',
|
|
115
|
+
validation: Z.number().min(1).max(100),
|
|
116
|
+
defaultValue: 20
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
notes: {
|
|
120
|
+
help: "Notes about this agent",
|
|
121
|
+
hint: {
|
|
122
|
+
type: 'text',
|
|
123
|
+
optional: true
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function assertUnreachable(_) {
|
|
131
|
+
throw new Error("Didn't expect to get here");
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../../src/util.openaiAgent/info.ts"],"names":[],"mappings":";;AAIA,4BAiIC;AAnID,+EAA4G;AAE5G,mBAAwB,EACtB,eAAe,EACf,UAAU,EAAE,EAAE,CAAC,EAAE,GACJ;IAEb,OAAO,eAAe,CAA4E;QAChG,UAAU,EAAE,kBAAkB;QAC9B,QAAQ,EAAE,WAAW;QACrB,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,yMAAyM;QACtN,YAAY,EAAE,EACb;QACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;QAClC,OAAO,EAAE;YACP,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC;gBACnB,MAAM,EAAE,MAAe;gBACvB,WAAW,EAAE,SAAS;gBACtB,gBAAgB,EAAE,CAAC;gBACnB,uBAAuB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AK,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE;4BAC1C,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,2BAA2B,EAAE;yBAC3D;wBACD,YAAY,EAAE,QAAQ;qBACvB;iBACF;gBACD,aAAa,EAAE;oBACb,IAAI,EAAE,uEAAuE;oBAC7E,IAAI,EAAE;wBACJ,IAAI,EAAE,MAAM;wBACZ,QAAQ,EAAE,IAAI;wBACd,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;wBAChC,YAAY,EAAE,0HAA0H;qBACzI;iBACF;gBACD,qBAAqB,EAAE;oBACrB,IAAI,EAAE,uDAAuD;oBAC7D,QAAQ,EAAE,IAAI;oBACd,IAAI,EAAE;wBACJ,IAAI,EAAE,SAAS;wBACf,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;wBACtC,YAAY,EAAE,EAAE;qBACjB;iBACF;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,wBAAwB;oBAC9B,IAAI,EAAE;wBACJ,IAAI,EAAE,MAAM;wBACZ,QAAQ,EAAE,IAAI;qBACf;iBACF;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,iBAAiB,CAAC,CAAQ;IACjC,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { Norsk } from '@norskvideo/norsk-sdk';
|
|
2
|
+
import { CreatedMediaNode, InstanceRouteArgs, OnCreated, RelatedMediaNodes, ServerComponentDefinition, ServerComponentSchemas, StudioRuntime } from '@norskvideo/norsk-studio/lib/extension/runtime-types';
|
|
3
|
+
import { InvocationTracker, TimerManager, MemoryManager, EventSubscriptionManager, TriggerContext } from '@norskvideo/norsk-studio-built-ins/lib/shared/agent';
|
|
4
|
+
import { components } from './_gen/types';
|
|
5
|
+
export type OpenAIAgentConfig = components['schemas']['OpenAIAgentConfig'];
|
|
6
|
+
export type OpenAIAgentState = components['schemas']['State'];
|
|
7
|
+
export type OpenAIAgentCommand = components['schemas']['Commands'];
|
|
8
|
+
export type OpenAIAgentEvent = components['schemas']['Events'];
|
|
9
|
+
export default class OpenAIAgentDefinition implements ServerComponentDefinition<OpenAIAgentConfig, OpenAIAgentNode, OpenAIAgentState, OpenAIAgentCommand, OpenAIAgentEvent> {
|
|
10
|
+
schemas(): Promise<ServerComponentSchemas>;
|
|
11
|
+
create(norsk: Norsk, cfg: OpenAIAgentConfig, cb: OnCreated<OpenAIAgentNode>, runtime: StudioRuntime<OpenAIAgentState, OpenAIAgentCommand, OpenAIAgentEvent>): Promise<void>;
|
|
12
|
+
handleCommand(node: OpenAIAgentNode, command: OpenAIAgentCommand): void;
|
|
13
|
+
instanceRoutes(): Promise<import("@norskvideo/norsk-studio/lib/extension/runtime-types").RouteInfo<InstanceRouteArgs<{
|
|
14
|
+
id: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
model?: string;
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
mission: string;
|
|
19
|
+
initialPrompt?: string;
|
|
20
|
+
maxStepsPerInvocation?: number;
|
|
21
|
+
notes?: string;
|
|
22
|
+
}, OpenAIAgentNode, {
|
|
23
|
+
status?: "idle" | "thinking" | "error";
|
|
24
|
+
currentTask?: string;
|
|
25
|
+
activeTimerCount?: number;
|
|
26
|
+
activeSubscriptionCount?: number;
|
|
27
|
+
invocationCount?: number;
|
|
28
|
+
lastActivity?: string;
|
|
29
|
+
errorMessage?: string;
|
|
30
|
+
}, {
|
|
31
|
+
type: "send_prompt";
|
|
32
|
+
prompt: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: "cancel_current";
|
|
35
|
+
} | {
|
|
36
|
+
type: "clear_memory";
|
|
37
|
+
} | {
|
|
38
|
+
type: "clear_timers";
|
|
39
|
+
} | {
|
|
40
|
+
type: "clear_subscriptions";
|
|
41
|
+
}, {
|
|
42
|
+
type: "agent_invoked";
|
|
43
|
+
trigger: string;
|
|
44
|
+
prompt: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: "agent_completed";
|
|
47
|
+
invocationId: string;
|
|
48
|
+
result: string;
|
|
49
|
+
toolsUsed?: string[];
|
|
50
|
+
durationMs?: number;
|
|
51
|
+
} | {
|
|
52
|
+
type: "timer_set";
|
|
53
|
+
timerId: string;
|
|
54
|
+
delayMs: number;
|
|
55
|
+
reason: string;
|
|
56
|
+
intervalMs?: number;
|
|
57
|
+
} | {
|
|
58
|
+
type: "timer_cancelled";
|
|
59
|
+
timerId: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: "timer_fired";
|
|
62
|
+
timerId: string;
|
|
63
|
+
reason: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: "subscription_added";
|
|
66
|
+
subscriptionId: string;
|
|
67
|
+
componentId: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: "subscription_removed";
|
|
70
|
+
subscriptionId: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "error_occurred";
|
|
73
|
+
error: string;
|
|
74
|
+
}>>[]>;
|
|
75
|
+
}
|
|
76
|
+
declare class OpenAIAgentNode implements CreatedMediaNode {
|
|
77
|
+
id: string;
|
|
78
|
+
relatedMediaNodes: RelatedMediaNodes;
|
|
79
|
+
norsk: Norsk;
|
|
80
|
+
cfg: OpenAIAgentConfig;
|
|
81
|
+
runtime: StudioRuntime<OpenAIAgentState, OpenAIAgentCommand, OpenAIAgentEvent>;
|
|
82
|
+
invocationTracker: InvocationTracker;
|
|
83
|
+
timerManager: TimerManager;
|
|
84
|
+
memoryManager: MemoryManager;
|
|
85
|
+
eventManager: EventSubscriptionManager;
|
|
86
|
+
private agent?;
|
|
87
|
+
private conversationHistory;
|
|
88
|
+
private invocationLock;
|
|
89
|
+
private currentTriggerType;
|
|
90
|
+
private currentTriggerSource?;
|
|
91
|
+
private runtimeToolsAdded;
|
|
92
|
+
private constructor();
|
|
93
|
+
static create(norsk: Norsk, cfg: OpenAIAgentConfig, runtime: StudioRuntime<OpenAIAgentState, OpenAIAgentCommand, OpenAIAgentEvent>): Promise<OpenAIAgentNode>;
|
|
94
|
+
private initialise;
|
|
95
|
+
private waitForToolsAndStart;
|
|
96
|
+
private createAgent;
|
|
97
|
+
private buildTools;
|
|
98
|
+
private jsonSchemaToZod;
|
|
99
|
+
private jsonSchemaPropertyToZod;
|
|
100
|
+
invokeAgent(message: string, trigger: TriggerContext): Promise<string>;
|
|
101
|
+
handleCommand(command: OpenAIAgentCommand): void;
|
|
102
|
+
}
|
|
103
|
+
export {};
|