@arbidocs/blocks 0.4.3 → 0.4.4

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.
@@ -12,7 +12,7 @@ import { testIdOr, prefixedTestId } from './chunk-7F6CBP3Z.js';
12
12
  import { memo, forwardRef, useState, useMemo, useId, useEffect, useRef, useCallback } from 'react';
13
13
  import { cn, Label, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Textarea, Input, Switch, Button, Collapsible, CollapsibleTrigger, CollapsibleContent, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Tooltip, TooltipTrigger, TooltipContent, Badge, Slider, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@arbidocs/react/ui';
14
14
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
15
- import { ChevronDown, ChevronRight, Plus, Trash2, Loader2, Play, Eye, ClipboardList, Pencil, Copy, Bot, Sparkles, Wand2, Globe, Download, Lock, ListChecks, AlertTriangle, FileX, SkipForward, X, Check, KeyRound, Pause, History, ListTodo, ChevronUp, Activity, Hourglass, MoreVertical, TriangleAlert, CheckSquare, Square, CheckCircle2, ArrowLeft, LayoutGrid, List } from 'lucide-react';
15
+ import { ChevronDown, ChevronRight, Plus, Trash2, Loader2, Play, Eye, ClipboardList, Pencil, Copy, Bot, Sparkles, Wand2, X, Globe, Download, Lock, ListChecks, AlertTriangle, FileX, SkipForward, Check, KeyRound, Pause, History, ListTodo, ChevronUp, Activity, Hourglass, MoreVertical, TriangleAlert, CheckSquare, Square, CheckCircle2, ArrowLeft, LayoutGrid, List } from 'lucide-react';
16
16
 
17
17
  // src/agents/workflows/types.ts
18
18
  var EMPTY_WORKFLOW_SCOPE = { folders: [], labels: [] };
@@ -1220,6 +1220,7 @@ var DEFAULT_AGENT_CREATOR_LABELS = {
1220
1220
  workspaceAccess: "Workspace access",
1221
1221
  workspaceAccessHint: "Each workspace stays separate. The agent can only read the ones you tick here.",
1222
1222
  workspaceAlready: "Already has access",
1223
+ revokeWorkspace: (name) => `Remove access to ${name}`,
1223
1224
  noWorkspacesToGrant: "You have no workspaces yet.",
1224
1225
  name: "Name",
1225
1226
  nameHint: "Letters, digits, - and _ only; must start with a letter or digit.",
@@ -1295,6 +1296,8 @@ function AgentCreator({
1295
1296
  models = [],
1296
1297
  workspaces = [],
1297
1298
  grantedWorkspaceIds = [],
1299
+ onRevokeWorkspace,
1300
+ revokingWorkspaceId,
1298
1301
  avatar,
1299
1302
  types,
1300
1303
  values: valuesProp,
@@ -1485,26 +1488,40 @@ function AgentCreator({
1485
1488
  workspaces.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: l.noWorkspacesToGrant }) : /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: workspaces.map((w) => {
1486
1489
  const already = grantedWorkspaceIds.includes(w.id);
1487
1490
  const on = already || values.workspaceIds.includes(w.id);
1488
- return /* @__PURE__ */ jsx(
1489
- "button",
1490
- {
1491
- type: "button",
1492
- role: "checkbox",
1493
- "aria-checked": on,
1494
- disabled: already,
1495
- title: already ? l.workspaceAlready : void 0,
1496
- "data-testid": `${id}-workspace-${w.id}`,
1497
- onClick: () => patch({
1498
- workspaceIds: on ? values.workspaceIds.filter((x) => x !== w.id) : [...values.workspaceIds, w.id]
1499
- }),
1500
- className: cn(
1501
- "rounded-md border px-3 py-1.5 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60 pointer-coarse:min-h-11",
1502
- on ? "border-primary bg-primary/10 text-primary" : "border-border [&:hover:not(:disabled)]:bg-accent"
1503
- ),
1504
- children: w.name
1505
- },
1506
- w.id
1507
- );
1491
+ return /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
1492
+ /* @__PURE__ */ jsx(
1493
+ "button",
1494
+ {
1495
+ type: "button",
1496
+ role: "checkbox",
1497
+ "aria-checked": on,
1498
+ disabled: already,
1499
+ title: already ? l.workspaceAlready : void 0,
1500
+ "data-testid": `${id}-workspace-${w.id}`,
1501
+ onClick: () => patch({
1502
+ workspaceIds: on ? values.workspaceIds.filter((x) => x !== w.id) : [...values.workspaceIds, w.id]
1503
+ }),
1504
+ className: cn(
1505
+ "rounded-md border px-3 py-1.5 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60 pointer-coarse:min-h-11",
1506
+ on ? "border-primary bg-primary/10 text-primary" : "border-border [&:hover:not(:disabled)]:bg-accent"
1507
+ ),
1508
+ children: w.name
1509
+ }
1510
+ ),
1511
+ already && onRevokeWorkspace && /* @__PURE__ */ jsx(
1512
+ "button",
1513
+ {
1514
+ type: "button",
1515
+ "aria-label": l.revokeWorkspace(w.name),
1516
+ title: l.revokeWorkspace(w.name),
1517
+ disabled: revokingWorkspaceId === w.id,
1518
+ "data-testid": `${id}-workspace-${w.id}-revoke`,
1519
+ onClick: () => onRevokeWorkspace(w.id),
1520
+ className: "flex size-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 pointer-coarse:size-11",
1521
+ children: /* @__PURE__ */ jsx(X, { className: "size-4", "aria-hidden": true })
1522
+ }
1523
+ )
1524
+ ] }, w.id);
1508
1525
  }) })
1509
1526
  ] }),
1510
1527
  models.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
@@ -1561,6 +1578,31 @@ function AgentCreator({
1561
1578
  }
1562
1579
  ) });
1563
1580
  }
1581
+
1582
+ // src/agents/definitions/persona.ts
1583
+ function composePersona(name, description) {
1584
+ const body = description.trim();
1585
+ const preamble = `You are ${name}, an AI agent.`;
1586
+ return body ? `${preamble} ${body}` : preamble;
1587
+ }
1588
+ function stripPersonaPreamble(persona) {
1589
+ return persona.replace(/^You are .+?, an AI agent\.\s*/, "").trim();
1590
+ }
1591
+ function agentCreatorToConfigSection(values, capabilityKeys) {
1592
+ return {
1593
+ PERSONA: composePersona(values.name, values.persona),
1594
+ ...values.modelName ? { AGENT_MODEL_NAME: values.modelName } : {},
1595
+ ...Object.fromEntries(capabilityKeys.map((k) => [k, !!values.capabilities[k]]))
1596
+ };
1597
+ }
1598
+ function agentConfigSectionToValues(section, capabilityKeys) {
1599
+ const s = section ?? {};
1600
+ return {
1601
+ persona: stripPersonaPreamble(String(s.PERSONA ?? "")),
1602
+ modelName: String(s.AGENT_MODEL_NAME ?? ""),
1603
+ capabilities: Object.fromEntries(capabilityKeys.map((k) => [k, Boolean(s[k])]))
1604
+ };
1605
+ }
1564
1606
  function SkillTypeBadge({ type, className }) {
1565
1607
  return /* @__PURE__ */ jsx(
1566
1608
  "span",
@@ -3866,6 +3908,106 @@ function TaskComposer({
3866
3908
  }
3867
3909
  ) });
3868
3910
  }
3911
+
3912
+ // src/agents/tasks/taskRequest.ts
3913
+ var TRIGGER_FOR = {
3914
+ now: "one_time",
3915
+ once: "one_time",
3916
+ repeat: "recurring",
3917
+ event: "event"
3918
+ };
3919
+ function authModeFor(values) {
3920
+ if (values.when === "now") return "run_now_temp";
3921
+ return values.access === "standing" ? "scheduled_permanent" : "scheduled_require_auth";
3922
+ }
3923
+ function localInputToIso(local) {
3924
+ const d = new Date(local);
3925
+ if (!local || Number.isNaN(d.getTime())) throw new Error("Pick a valid date and time.");
3926
+ return d.toISOString();
3927
+ }
3928
+ function isoToLocalInput(iso) {
3929
+ if (!iso) return "";
3930
+ const d = new Date(iso);
3931
+ if (Number.isNaN(d.getTime())) return "";
3932
+ return new Date(d.getTime() - d.getTimezoneOffset() * 6e4).toISOString().slice(0, 16);
3933
+ }
3934
+ function workflowTaskFields(workflow, inputs, name) {
3935
+ const typed = name?.trim();
3936
+ if (workflow.options?.agent === false) {
3937
+ const message = composeWorkflowPrompt(workflow, inputs);
3938
+ return { name: typed || message, action_type: "notify", prompt: "", skill_ref: null };
3939
+ }
3940
+ if (workflow.skill) {
3941
+ return {
3942
+ name: typed || workflow.title,
3943
+ action_type: "run_skill",
3944
+ prompt: typeof inputs.args === "string" ? inputs.args.trim() : "",
3945
+ skill_ref: workflow.skill
3946
+ };
3947
+ }
3948
+ return {
3949
+ name: typed || workflow.title,
3950
+ action_type: "agent_prompt",
3951
+ prompt: composeWorkflowPrompt(workflow, inputs),
3952
+ skill_ref: null
3953
+ };
3954
+ }
3955
+ var isAgenticWorkflow = (workflow) => workflow.options?.agent !== false;
3956
+ function taskComposerToCreateRequest({ workflow, values }, workspaceId) {
3957
+ const fields = workflowTaskFields(workflow, values.inputs, values.name);
3958
+ const agentic = isAgenticWorkflow(workflow);
3959
+ if (agentic && !workspaceId) throw new Error("Open a workspace to run an agent task.");
3960
+ return {
3961
+ name: fields.name,
3962
+ trigger_type: TRIGGER_FOR[values.when],
3963
+ timezone: values.timezone,
3964
+ action_type: fields.action_type,
3965
+ prompt: fields.prompt,
3966
+ rrule: values.when === "repeat" ? values.rrule.trim() : null,
3967
+ run_at: values.when === "once" ? localInputToIso(values.runAt) : values.when === "now" ? (/* @__PURE__ */ new Date()).toISOString() : null,
3968
+ event_kind: values.when === "event" ? values.eventKind.trim() : null,
3969
+ skill_ref: fields.skill_ref,
3970
+ notify_on_complete: values.notifyOnComplete,
3971
+ auth_mode: authModeFor(values),
3972
+ workspace_ext_id: agentic ? workspaceId ?? null : null,
3973
+ agent_ext_id: values.agentId || null
3974
+ };
3975
+ }
3976
+ function taskComposerToUpdateRequest({
3977
+ workflow,
3978
+ values
3979
+ }) {
3980
+ const fields = workflowTaskFields(workflow, values.inputs, values.name);
3981
+ return {
3982
+ name: fields.name,
3983
+ rrule: values.when === "repeat" ? values.rrule.trim() : null,
3984
+ run_at: values.when === "once" && values.runAt ? localInputToIso(values.runAt) : null,
3985
+ timezone: values.timezone,
3986
+ prompt: fields.prompt,
3987
+ skill_ref: fields.skill_ref,
3988
+ notify_on_complete: values.notifyOnComplete,
3989
+ auth_mode: authModeFor(values)
3990
+ };
3991
+ }
3992
+ var taskNeedsAccess = (task) => !!task.pending_auth_request_id;
3993
+ function taskToComposerValues(task, workflows) {
3994
+ const reminder = task.action_type === "notify";
3995
+ const auth = task.auth_mode ?? "scheduled_permanent";
3996
+ const when = auth === "run_now_temp" ? "now" : task.trigger_type === "recurring" ? "repeat" : task.trigger_type === "event" ? "event" : "once";
3997
+ return {
3998
+ workflowId: reminder ? workflows.reminderWorkflowId : workflows.customWorkflowId,
3999
+ inputs: reminder ? { message: task.name } : { instruction: task.prompt },
4000
+ when,
4001
+ runAt: isoToLocalInput(task.run_at),
4002
+ rrule: task.rrule ?? "",
4003
+ timezone: task.timezone,
4004
+ eventKind: task.event_kind ?? "user_message",
4005
+ agentId: task.agent_ext_id ?? "",
4006
+ name: task.name,
4007
+ notifyOnComplete: task.notify_on_complete ?? false,
4008
+ access: auth === "scheduled_permanent" ? "standing" : "ask_each_run"
4009
+ };
4010
+ }
3869
4011
  var DEFAULT_TUPLE_ARRAY_FIELD_LABELS = {
3870
4012
  addRow: "Add Row",
3871
4013
  empty: 'No examples added yet. Click "Add Row" to start.',
@@ -5524,6 +5666,6 @@ function AgentCreateView({
5524
5666
  ] });
5525
5667
  }
5526
5668
 
5527
- export { ACTION_LABELS, AgentAvatarField, AgentBar, AgentBarIconButton, AgentBarMenu, AgentBarNotes, AgentBarProbeAnswer, AgentBarQueuedNote, AgentBarStatus, AgentCard, AgentCreateView, AgentCreatedView, AgentCreator, AgentEditView, AgentGallery, AgentMainView, AgentSelect, AgentTypeSelector, CapabilityGrid, CapabilityTile, ConfigField, ConfigForm, ConsentActions, ConsentBulletList, ConsentCard, ConsentFootnote, ConsentHeader, ConsentMessage, ConsentNotice, ConsentPage, ConsentPermissionList, ConsentSection, ConsentStrong, ConsentText, CopyableUrl, DEFAULT_AGENT_AVATAR_FIELD_LABELS, DEFAULT_AGENT_BAR_LABELS, DEFAULT_AGENT_CARD_LABELS, DEFAULT_AGENT_CREATOR_LABELS, DEFAULT_AGENT_GALLERY_LABELS, DEFAULT_AGENT_SELECT_LABELS, DEFAULT_AGENT_STEPS_LABELS, DEFAULT_AGENT_TYPE_SELECTOR_LABELS, DEFAULT_AUTHORIZE_AGENT_LABELS, DEFAULT_CONFIG_FIELD_LABELS, DEFAULT_CONFIG_FORM_LABELS, DEFAULT_CONSENT_ACTIONS_LABELS, DEFAULT_COPYABLE_URL_LABELS, DEFAULT_LIVE_RUNS_BANNER_LABELS, DEFAULT_RECURRENCE, DEFAULT_RECURRENCE_BUILDER_LABELS, DEFAULT_SCHEMA_FORM_LABELS, DEFAULT_SKILL_CARD_LABELS, DEFAULT_SKILL_EDIT_FORM_LABELS, DEFAULT_SKILL_GENERATE_FORM_LABELS, DEFAULT_SKILL_GLOBAL_BADGE_LABELS, DEFAULT_SKILL_ROW_LABELS, DEFAULT_SKILL_VIEW_TOGGLE_LABELS, DEFAULT_SUBAGENT_ROSTER_LABELS, DEFAULT_TASKS_CHROME_LABELS, DEFAULT_TASK_COLUMN_LABELS, DEFAULT_TASK_COMPOSER_LABELS, DEFAULT_TASK_PLAN_LABELS, DEFAULT_TASK_ROW_ACTIONS_LABELS, DEFAULT_TASK_RUNS_DIALOG_LABELS, DEFAULT_TUPLE_ARRAY_FIELD_LABELS, DEFAULT_UPLOAD_TASK_ITEM_LABELS, DEFAULT_UPLOAD_TASK_LIST_LABELS, DEFAULT_WORKFLOW_CONFIG_DIALOG_LABELS, EMPTY_WORKFLOW_SCOPE, GoalCriteria, LiveRunsBanner, NewTaskEmptyAction, RecurrenceBuilder, SKILL_PROMPT_FALLBACK_PLACEHOLDER, SKILL_PROMPT_LABEL, STATUS_LABELS, SchemaForm, SkillActionButton, SkillCard, SkillDetail, SkillDetailSection, SkillEditForm, SkillFilterChips, SkillGenerateForm, SkillGlobalBadge, SkillRow, SkillTile, SkillTypeBadge, SkillViewToggle, StepDetail, StepNarration, StepOutcome, StepParams, StepRow, StepSummary, StepTrace, StepTraceSummary, SubAgentLane, SubStepGroup, SubagentRoster, TRIGGER_LABELS, TaskComposer, TaskPlan, TaskRowActions, TaskRunsDialog, TasksBulkBar, TasksToolbar, TupleArrayField, UploadTaskItem, UploadTaskList, WEEKDAYS, WorkflowConfigDialog, WorkflowLauncher, buildLaunch, buildRRule, composeWorkflowPrompt, createTaskColumns, defaultInputs, defaultTaskComposerValues, deriveAgentName, describeRRule, formatElapsed, goalProgress, humanizeSection, inferType, inputsFromContext, isEmptyWorkflowScope, isOutOfBounds, isValidAgentName, isWorkflowScope, nextCriterionId, parseRRule, prettifyKey, promptFieldName, skillToWorkflow, statusBadgeVariant, summarizeAgent, summarizeCapabilities, validateInputs, workflowAccepts, workflowFromFrontmatter, workflowsAccepting, workflowsForHost };
5528
- //# sourceMappingURL=chunk-AAY5ASZD.js.map
5529
- //# sourceMappingURL=chunk-AAY5ASZD.js.map
5669
+ export { ACTION_LABELS, AgentAvatarField, AgentBar, AgentBarIconButton, AgentBarMenu, AgentBarNotes, AgentBarProbeAnswer, AgentBarQueuedNote, AgentBarStatus, AgentCard, AgentCreateView, AgentCreatedView, AgentCreator, AgentEditView, AgentGallery, AgentMainView, AgentSelect, AgentTypeSelector, CapabilityGrid, CapabilityTile, ConfigField, ConfigForm, ConsentActions, ConsentBulletList, ConsentCard, ConsentFootnote, ConsentHeader, ConsentMessage, ConsentNotice, ConsentPage, ConsentPermissionList, ConsentSection, ConsentStrong, ConsentText, CopyableUrl, DEFAULT_AGENT_AVATAR_FIELD_LABELS, DEFAULT_AGENT_BAR_LABELS, DEFAULT_AGENT_CARD_LABELS, DEFAULT_AGENT_CREATOR_LABELS, DEFAULT_AGENT_GALLERY_LABELS, DEFAULT_AGENT_SELECT_LABELS, DEFAULT_AGENT_STEPS_LABELS, DEFAULT_AGENT_TYPE_SELECTOR_LABELS, DEFAULT_AUTHORIZE_AGENT_LABELS, DEFAULT_CONFIG_FIELD_LABELS, DEFAULT_CONFIG_FORM_LABELS, DEFAULT_CONSENT_ACTIONS_LABELS, DEFAULT_COPYABLE_URL_LABELS, DEFAULT_LIVE_RUNS_BANNER_LABELS, DEFAULT_RECURRENCE, DEFAULT_RECURRENCE_BUILDER_LABELS, DEFAULT_SCHEMA_FORM_LABELS, DEFAULT_SKILL_CARD_LABELS, DEFAULT_SKILL_EDIT_FORM_LABELS, DEFAULT_SKILL_GENERATE_FORM_LABELS, DEFAULT_SKILL_GLOBAL_BADGE_LABELS, DEFAULT_SKILL_ROW_LABELS, DEFAULT_SKILL_VIEW_TOGGLE_LABELS, DEFAULT_SUBAGENT_ROSTER_LABELS, DEFAULT_TASKS_CHROME_LABELS, DEFAULT_TASK_COLUMN_LABELS, DEFAULT_TASK_COMPOSER_LABELS, DEFAULT_TASK_PLAN_LABELS, DEFAULT_TASK_ROW_ACTIONS_LABELS, DEFAULT_TASK_RUNS_DIALOG_LABELS, DEFAULT_TUPLE_ARRAY_FIELD_LABELS, DEFAULT_UPLOAD_TASK_ITEM_LABELS, DEFAULT_UPLOAD_TASK_LIST_LABELS, DEFAULT_WORKFLOW_CONFIG_DIALOG_LABELS, EMPTY_WORKFLOW_SCOPE, GoalCriteria, LiveRunsBanner, NewTaskEmptyAction, RecurrenceBuilder, SKILL_PROMPT_FALLBACK_PLACEHOLDER, SKILL_PROMPT_LABEL, STATUS_LABELS, SchemaForm, SkillActionButton, SkillCard, SkillDetail, SkillDetailSection, SkillEditForm, SkillFilterChips, SkillGenerateForm, SkillGlobalBadge, SkillRow, SkillTile, SkillTypeBadge, SkillViewToggle, StepDetail, StepNarration, StepOutcome, StepParams, StepRow, StepSummary, StepTrace, StepTraceSummary, SubAgentLane, SubStepGroup, SubagentRoster, TRIGGER_LABELS, TaskComposer, TaskPlan, TaskRowActions, TaskRunsDialog, TasksBulkBar, TasksToolbar, TupleArrayField, UploadTaskItem, UploadTaskList, WEEKDAYS, WorkflowConfigDialog, WorkflowLauncher, agentConfigSectionToValues, agentCreatorToConfigSection, authModeFor, buildLaunch, buildRRule, composePersona, composeWorkflowPrompt, createTaskColumns, defaultInputs, defaultTaskComposerValues, deriveAgentName, describeRRule, formatElapsed, goalProgress, humanizeSection, inferType, inputsFromContext, isAgenticWorkflow, isEmptyWorkflowScope, isOutOfBounds, isValidAgentName, isWorkflowScope, isoToLocalInput, localInputToIso, nextCriterionId, parseRRule, prettifyKey, promptFieldName, skillToWorkflow, statusBadgeVariant, stripPersonaPreamble, summarizeAgent, summarizeCapabilities, taskComposerToCreateRequest, taskComposerToUpdateRequest, taskNeedsAccess, taskToComposerValues, validateInputs, workflowAccepts, workflowFromFrontmatter, workflowTaskFields, workflowsAccepting, workflowsForHost };
5670
+ //# sourceMappingURL=chunk-BBEMPS6C.js.map
5671
+ //# sourceMappingURL=chunk-BBEMPS6C.js.map