@inferencesh/sdk 0.6.30 → 0.6.48
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 +35 -0
- package/dist/agent/actions.js +72 -13
- package/dist/agent/api.d.ts +30 -51
- package/dist/agent/api.js +129 -154
- package/dist/agent/provider.js +18 -1
- package/dist/agent/reducer.js +50 -11
- package/dist/agent/types.d.ts +34 -1
- package/dist/api/agents.d.ts +23 -14
- package/dist/api/agents.js +22 -4
- package/dist/api/api-keys.d.ts +4 -3
- package/dist/api/apps.d.ts +16 -15
- package/dist/api/chats.d.ts +14 -9
- package/dist/api/chats.js +6 -0
- package/dist/api/engines.d.ts +14 -13
- package/dist/api/files.d.ts +4 -3
- package/dist/api/files.js +2 -2
- package/dist/api/flow-runs.d.ts +8 -7
- package/dist/api/flows.d.ts +11 -10
- package/dist/api/integrations.d.ts +9 -8
- package/dist/api/integrations.js +8 -8
- package/dist/api/knowledge.d.ts +25 -24
- package/dist/api/mcp-servers.d.ts +10 -9
- package/dist/api/projects.d.ts +6 -5
- package/dist/api/search.d.ts +3 -2
- package/dist/api/secrets.d.ts +6 -5
- package/dist/api/sessions.d.ts +5 -4
- package/dist/api/sessions.js +2 -3
- package/dist/api/tasks.d.ts +14 -11
- package/dist/api/tasks.js +10 -4
- package/dist/api/teams.d.ts +16 -17
- package/dist/delta.d.ts +15 -0
- package/dist/delta.js +84 -0
- package/dist/hook-builder.d.ts +23 -0
- package/dist/hook-builder.js +50 -0
- package/dist/http/client.d.ts +9 -1
- package/dist/http/client.js +12 -3
- package/dist/http/response.d.ts +9 -0
- package/dist/http/response.js +1 -0
- package/dist/http/stream.d.ts +1 -0
- package/dist/http/stream.js +8 -3
- package/dist/http/streamable.d.ts +3 -1
- package/dist/http/streamable.js +10 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.js +6 -1
- package/dist/proxy/index.d.ts +2 -0
- package/dist/proxy/index.js +9 -0
- package/dist/tool-builder.d.ts +2 -0
- package/dist/tool-builder.js +5 -0
- package/dist/types.d.ts +1036 -157
- package/dist/types.js +246 -30
- package/dist/utils.d.ts +13 -0
- package/dist/utils.js +43 -3
- package/package.json +20 -24
package/dist/types.js
CHANGED
|
@@ -211,6 +211,16 @@ export const ScopeApiKeysRead = "apikeys:read";
|
|
|
211
211
|
* Empty scopes = full access (for backwards compatibility with existing keys).
|
|
212
212
|
*/
|
|
213
213
|
export const ScopeApiKeysWrite = "apikeys:write";
|
|
214
|
+
/**
|
|
215
|
+
* Action-level scopes for Knowledge (includes skills)
|
|
216
|
+
*/
|
|
217
|
+
export const ScopeKnowledgeRead = "knowledge:read";
|
|
218
|
+
/**
|
|
219
|
+
* API Key Scopes - hierarchical permission system.
|
|
220
|
+
* Resource-level scopes (e.g., "agents") imply all action-level scopes (e.g., "agents:read").
|
|
221
|
+
* Empty scopes = full access (for backwards compatibility with existing keys).
|
|
222
|
+
*/
|
|
223
|
+
export const ScopeKnowledgeWrite = "knowledge:write";
|
|
214
224
|
/**
|
|
215
225
|
* Action-level scopes for User profile
|
|
216
226
|
*/
|
|
@@ -244,8 +254,85 @@ export const ScopeGroupSecrets = "secrets";
|
|
|
244
254
|
export const ScopeGroupIntegrations = "integrations";
|
|
245
255
|
export const ScopeGroupEngines = "engines";
|
|
246
256
|
export const ScopeGroupApiKeys = "apikeys";
|
|
257
|
+
export const ScopeGroupKnowledge = "knowledge";
|
|
247
258
|
export const ScopeGroupUser = "user";
|
|
248
259
|
export const ScopeGroupSettings = "settings";
|
|
260
|
+
/**
|
|
261
|
+
* Flow graph action type constants.
|
|
262
|
+
*/
|
|
263
|
+
export const ActionNodeAdd = "node.add";
|
|
264
|
+
/**
|
|
265
|
+
* Flow graph action type constants.
|
|
266
|
+
*/
|
|
267
|
+
export const ActionNodeRemove = "node.remove";
|
|
268
|
+
/**
|
|
269
|
+
* Flow graph action type constants.
|
|
270
|
+
*/
|
|
271
|
+
export const ActionNodeMove = "node.move";
|
|
272
|
+
/**
|
|
273
|
+
* Flow graph action type constants.
|
|
274
|
+
*/
|
|
275
|
+
export const ActionNodeMoveMany = "node.move_many";
|
|
276
|
+
/**
|
|
277
|
+
* Flow graph action type constants.
|
|
278
|
+
*/
|
|
279
|
+
export const ActionNodeDuplicate = "node.duplicate";
|
|
280
|
+
/**
|
|
281
|
+
* Flow graph action type constants.
|
|
282
|
+
*/
|
|
283
|
+
export const ActionNodeRename = "node.rename";
|
|
284
|
+
/**
|
|
285
|
+
* Flow graph action type constants.
|
|
286
|
+
*/
|
|
287
|
+
export const ActionNodeSetApp = "node.set_app";
|
|
288
|
+
/**
|
|
289
|
+
* Flow graph action type constants.
|
|
290
|
+
*/
|
|
291
|
+
export const ActionNodeUpdate = "node.update";
|
|
292
|
+
/**
|
|
293
|
+
* Flow graph action type constants.
|
|
294
|
+
*/
|
|
295
|
+
export const ActionNodeSetInput = "node.set_input";
|
|
296
|
+
/**
|
|
297
|
+
* Flow graph action type constants.
|
|
298
|
+
*/
|
|
299
|
+
export const ActionNodeClearInput = "node.clear_input";
|
|
300
|
+
/**
|
|
301
|
+
* Flow graph action type constants.
|
|
302
|
+
*/
|
|
303
|
+
export const ActionEdgeAdd = "edge.add";
|
|
304
|
+
/**
|
|
305
|
+
* Flow graph action type constants.
|
|
306
|
+
*/
|
|
307
|
+
export const ActionEdgeRemove = "edge.remove";
|
|
308
|
+
/**
|
|
309
|
+
* Flow graph action type constants.
|
|
310
|
+
*/
|
|
311
|
+
export const ActionFlowSetInputSchema = "flow.set_input_schema";
|
|
312
|
+
/**
|
|
313
|
+
* Flow graph action type constants.
|
|
314
|
+
*/
|
|
315
|
+
export const ActionFlowSetOutputSchema = "flow.set_output_schema";
|
|
316
|
+
/**
|
|
317
|
+
* Flow graph action type constants.
|
|
318
|
+
*/
|
|
319
|
+
export const ActionFlowSetOutputMapping = "flow.set_output_mapping";
|
|
320
|
+
/**
|
|
321
|
+
* Flow graph action type constants.
|
|
322
|
+
*/
|
|
323
|
+
export const ActionFlowRemoveOutputMapping = "flow.remove_output_mapping";
|
|
324
|
+
/**
|
|
325
|
+
* Flow graph action type constants.
|
|
326
|
+
*/
|
|
327
|
+
export const ActionFlowRenameOutputField = "flow.rename_output_field";
|
|
328
|
+
/**
|
|
329
|
+
* Flow graph action type constants.
|
|
330
|
+
*/
|
|
331
|
+
export const ActionUndo = "undo";
|
|
332
|
+
/**
|
|
333
|
+
* Flow graph action type constants.
|
|
334
|
+
*/
|
|
335
|
+
export const ActionRedo = "redo";
|
|
249
336
|
export const ElicitActionAccept = "accept";
|
|
250
337
|
export const ElicitActionDecline = "decline";
|
|
251
338
|
export const ElicitActionCancel = "cancel";
|
|
@@ -287,6 +374,72 @@ export const RequirementTypeScope = "scope";
|
|
|
287
374
|
export const SetupActionAddSecret = "add_secret";
|
|
288
375
|
export const SetupActionConnect = "connect";
|
|
289
376
|
export const SetupActionAddScopes = "add_scopes";
|
|
377
|
+
export const A2UIRow = "Row";
|
|
378
|
+
export const A2UIColumn = "Column";
|
|
379
|
+
export const A2UIList = "List";
|
|
380
|
+
export const A2UIText = "Text";
|
|
381
|
+
export const A2UIImage = "Image";
|
|
382
|
+
export const A2UIIcon = "Icon";
|
|
383
|
+
export const A2UIDivider = "Divider";
|
|
384
|
+
export const A2UIButton = "Button";
|
|
385
|
+
export const A2UITextField = "TextField";
|
|
386
|
+
export const A2UICheckBox = "CheckBox";
|
|
387
|
+
export const A2UISlider = "Slider";
|
|
388
|
+
export const A2UIDateTimeInput = "DateTimeInput";
|
|
389
|
+
export const A2UIChoicePicker = "ChoicePicker";
|
|
390
|
+
export const A2UICard = "Card";
|
|
391
|
+
export const A2UIModal = "Modal";
|
|
392
|
+
export const A2UITabs = "Tabs";
|
|
393
|
+
/**
|
|
394
|
+
* Extensions (inferencesh/v1 catalog)
|
|
395
|
+
*/
|
|
396
|
+
export const A2UIBadge = "Badge";
|
|
397
|
+
export const A2UISpacer = "Spacer";
|
|
398
|
+
export const A2UIChart = "Chart";
|
|
399
|
+
export const A2UIForm = "Form";
|
|
400
|
+
/**
|
|
401
|
+
* Run lifecycle
|
|
402
|
+
*/
|
|
403
|
+
export const AgentEventRunStarted = "run.started";
|
|
404
|
+
export const AgentEventRunStateChanged = "run.state_changed";
|
|
405
|
+
/**
|
|
406
|
+
* Turn lifecycle
|
|
407
|
+
*/
|
|
408
|
+
export const AgentEventTurnStarted = "turn.started";
|
|
409
|
+
export const AgentEventTurnCompleted = "turn.completed";
|
|
410
|
+
/**
|
|
411
|
+
* Content streaming — structural wrapper; high-frequency token deltas
|
|
412
|
+
* still flow via the existing DeltaEvent channel for efficiency.
|
|
413
|
+
*/
|
|
414
|
+
export const AgentEventContentDelta = "content.delta";
|
|
415
|
+
/**
|
|
416
|
+
* Tool lifecycle
|
|
417
|
+
*/
|
|
418
|
+
export const AgentEventToolStarted = "tool.started";
|
|
419
|
+
export const AgentEventToolCompleted = "tool.completed";
|
|
420
|
+
/**
|
|
421
|
+
* Approval flow
|
|
422
|
+
*/
|
|
423
|
+
export const AgentEventApprovalRequired = "approval.required";
|
|
424
|
+
export const AgentEventApprovalResolved = "approval.resolved";
|
|
425
|
+
/**
|
|
426
|
+
* Hook lifecycle
|
|
427
|
+
*/
|
|
428
|
+
export const AgentEventHookExecuted = "hook.executed";
|
|
429
|
+
/**
|
|
430
|
+
* Usage
|
|
431
|
+
*/
|
|
432
|
+
export const AgentEventUsageUpdated = "usage.updated";
|
|
433
|
+
/**
|
|
434
|
+
* Context management
|
|
435
|
+
*/
|
|
436
|
+
export const AgentEventContextCompacted = "context.compacted";
|
|
437
|
+
/**
|
|
438
|
+
* Errors
|
|
439
|
+
*/
|
|
440
|
+
export const AgentEventError = "error";
|
|
441
|
+
export const ContentDeltaText = "text";
|
|
442
|
+
export const ContentDeltaReasoning = "reasoning";
|
|
290
443
|
export const AgentRunStateSubmitted = "submitted";
|
|
291
444
|
export const AgentRunStateWorking = "working";
|
|
292
445
|
export const AgentRunStateInputRequired = "input_required";
|
|
@@ -300,6 +453,7 @@ export const InterruptReasonClientTool = "client_tool";
|
|
|
300
453
|
export const InterruptReasonWidget = "widget";
|
|
301
454
|
export const InterruptReasonAuth = "auth";
|
|
302
455
|
export const InterruptReasonConfirmation = "confirmation";
|
|
456
|
+
export const InterruptReasonHookGate = "hook_gate";
|
|
303
457
|
export const AppCategoryImage = "image";
|
|
304
458
|
export const AppCategoryVideo = "video";
|
|
305
459
|
export const AppCategoryAudio = "audio";
|
|
@@ -319,8 +473,16 @@ export const GPUTypeNvidia = "nvidia";
|
|
|
319
473
|
export const GPUTypeAMD = "amd";
|
|
320
474
|
export const GPUTypeApple = "apple";
|
|
321
475
|
export const VisibilityPrivate = "private";
|
|
476
|
+
export const VisibilityTeam = "team";
|
|
477
|
+
/**
|
|
478
|
+
* VisibilityOrg sits between team and public: visible to every member of
|
|
479
|
+
* every team in the owning team's org (INF-795 Phase 2).
|
|
480
|
+
*/
|
|
481
|
+
export const VisibilityOrg = "org";
|
|
322
482
|
export const VisibilityPublic = "public";
|
|
323
483
|
export const VisibilityUnlisted = "unlisted";
|
|
484
|
+
export const PermRead = "read";
|
|
485
|
+
export const PermWrite = "write";
|
|
324
486
|
export const SubscriptionStatusTrialing = "trialing";
|
|
325
487
|
export const SubscriptionStatusActive = "active";
|
|
326
488
|
export const SubscriptionStatusPastDue = "past_due";
|
|
@@ -347,11 +509,21 @@ export const PlanStepStatusPending = "pending";
|
|
|
347
509
|
export const PlanStepStatusInProgress = "in_progress";
|
|
348
510
|
export const PlanStepStatusCompleted = "completed";
|
|
349
511
|
export const PlanStepStatusCancelled = "cancelled";
|
|
512
|
+
/**
|
|
513
|
+
* LLM wire-protocol roles
|
|
514
|
+
*/
|
|
350
515
|
export const ChatMessageRoleSystem = "system";
|
|
351
516
|
export const ChatMessageRoleUser = "user";
|
|
352
517
|
export const ChatMessageRoleAssistant = "assistant";
|
|
353
518
|
export const ChatMessageRoleTool = "tool";
|
|
519
|
+
/**
|
|
520
|
+
* Internal bookkeeping roles — never sent to the LLM provider.
|
|
521
|
+
* BuildContext converts these to system messages or skips them.
|
|
522
|
+
*/
|
|
523
|
+
export const ChatMessageRoleInjection = "injection";
|
|
524
|
+
export const ChatMessageRoleCompaction = "compaction";
|
|
354
525
|
export const ChatMessageStatusPending = "pending";
|
|
526
|
+
export const ChatMessageStatusQueued = "queued";
|
|
355
527
|
export const ChatMessageStatusReady = "ready";
|
|
356
528
|
export const ChatMessageStatusFailed = "failed";
|
|
357
529
|
export const ChatMessageStatusCancelled = "cancelled";
|
|
@@ -413,6 +585,57 @@ export const GraphEdgeTypeReferences = "references";
|
|
|
413
585
|
export const GraphEdgeTypeSupersedes = "supersedes";
|
|
414
586
|
export const GraphEdgeTypeInput = "input";
|
|
415
587
|
export const GraphEdgeTypeOutput = "output";
|
|
588
|
+
export const InterruptStatusPending = "pending";
|
|
589
|
+
export const InterruptStatusResolved = "resolved";
|
|
590
|
+
export const InterruptStatusExpired = "expired";
|
|
591
|
+
export const InterruptStatusCancelled = "cancelled";
|
|
592
|
+
export const InterruptResolutionAllow = "allow";
|
|
593
|
+
export const InterruptResolutionDeny = "deny";
|
|
594
|
+
export const InterruptResourceToolInvocation = "tool_invocation";
|
|
595
|
+
export const InterruptResourceHookEvent = "hook_event";
|
|
596
|
+
export const HookEventAgentStart = "agent.start";
|
|
597
|
+
export const HookEventTurnStart = "agent.turn_start";
|
|
598
|
+
export const HookEventToolCall = "agent.tool_call";
|
|
599
|
+
export const HookEventToolResult = "agent.tool_result";
|
|
600
|
+
export const HookEventTurnComplete = "agent.turn_complete";
|
|
601
|
+
export const HookEventAgentError = "agent.error";
|
|
602
|
+
export const HookEventAgentComplete = "agent.complete";
|
|
603
|
+
export const HookEventAgentIdle = "agent.idle";
|
|
604
|
+
export const HookEventPreCompact = "agent.pre_compact";
|
|
605
|
+
export const HookEventPostCompact = "agent.post_compact";
|
|
606
|
+
export const HookDecisionAllow = "allow";
|
|
607
|
+
export const HookDecisionDeny = "deny";
|
|
608
|
+
export const HookDecisionStop = "stop";
|
|
609
|
+
export const HookDecisionSuspend = "suspend";
|
|
610
|
+
export const HookHandlerWebhook = "webhook";
|
|
611
|
+
export const HookHandlerTask = "task";
|
|
612
|
+
export const HookHandlerGate = "gate";
|
|
613
|
+
export const MergeStrategyConcat = "concat";
|
|
614
|
+
export const MergeStrategyReplace = "replace";
|
|
615
|
+
export const MergeStrategyIndexed = "indexed";
|
|
616
|
+
export const MergeStrategyNested = "nested";
|
|
617
|
+
export const LLMDelta_fieldTags = {
|
|
618
|
+
response: { merge: "concat" },
|
|
619
|
+
reasoning: { merge: "concat" },
|
|
620
|
+
tool_calls: { merge: "indexed" },
|
|
621
|
+
usage: { merge: "replace" },
|
|
622
|
+
};
|
|
623
|
+
export const ToolCallDelta_fieldTags = {
|
|
624
|
+
id: { merge: "replace" },
|
|
625
|
+
type: { merge: "replace" },
|
|
626
|
+
function: { merge: "nested" },
|
|
627
|
+
};
|
|
628
|
+
export const ToolCallFunctionDelta_fieldTags = {
|
|
629
|
+
name: { merge: "replace" },
|
|
630
|
+
arguments: { merge: "concat" },
|
|
631
|
+
};
|
|
632
|
+
export const ToolChoiceModeNone = "none";
|
|
633
|
+
export const ToolChoiceModeAuto = "auto";
|
|
634
|
+
export const ToolChoiceModeRequired = "required";
|
|
635
|
+
export const ToolChoiceModeFunction = "function";
|
|
636
|
+
export const ResponseFormatTypeText = "text";
|
|
637
|
+
export const ResponseFormatTypeJSONObject = "json_object";
|
|
638
|
+
export const ResponseFormatTypeJSONSchema = "json_schema";
|
|
416
639
|
/**
|
|
417
640
|
* SecretScopeTeam is a normal user secret, visible in team secret lists
|
|
418
641
|
*/
|
|
@@ -433,6 +656,7 @@ export const PageStatusScheduled = 4;
|
|
|
433
656
|
export const PageTypeDoc = "doc";
|
|
434
657
|
export const PageTypeBlog = "blog";
|
|
435
658
|
export const PageTypePage = "page";
|
|
659
|
+
export const PageTypeAnnouncement = "announcement";
|
|
436
660
|
export const ToolInvocationStatusPending = "pending";
|
|
437
661
|
export const ToolInvocationStatusInProgress = "in_progress";
|
|
438
662
|
export const ToolInvocationStatusAwaitingInput = "awaiting_input";
|
|
@@ -527,6 +751,8 @@ export const KnowledgeTypeProject = "project";
|
|
|
527
751
|
export const KnowledgeTypeAgentConfig = "agent-config";
|
|
528
752
|
export const KnowledgeLifecyclePermanent = "permanent";
|
|
529
753
|
export const KnowledgeLifecycleDecay = "decay";
|
|
754
|
+
export const KnowledgeLifecycleDraft = "draft";
|
|
755
|
+
export const KnowledgeLifecycleDeprecated = "deprecated";
|
|
530
756
|
export const OpEqual = "eq";
|
|
531
757
|
export const OpNotEqual = "neq";
|
|
532
758
|
export const OpIn = "in";
|
|
@@ -620,40 +846,29 @@ export const IntegrationStatusConnected = "connected";
|
|
|
620
846
|
export const IntegrationStatusDisconnected = "disconnected";
|
|
621
847
|
export const IntegrationStatusExpired = "expired";
|
|
622
848
|
export const IntegrationStatusError = "error";
|
|
849
|
+
export const IntegrationScopeTeam = "team";
|
|
850
|
+
export const IntegrationScopePlatform = "platform";
|
|
851
|
+
export const IntegrationScopeUser = "user";
|
|
623
852
|
/**
|
|
624
|
-
*
|
|
853
|
+
* IntegrationGrantCredentials provides OAuth app credentials (client_id/secret).
|
|
854
|
+
* Users connect their own accounts against it. Only valid for type=oauth.
|
|
625
855
|
*/
|
|
626
|
-
export const
|
|
856
|
+
export const IntegrationGrantCredentials = "credentials";
|
|
627
857
|
/**
|
|
628
|
-
*
|
|
858
|
+
* IntegrationGrantToken provides ready-to-use access (token, API key, etc.).
|
|
629
859
|
*/
|
|
630
|
-
export const
|
|
631
|
-
export const
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
export const
|
|
639
|
-
export const
|
|
640
|
-
export const
|
|
641
|
-
export const
|
|
642
|
-
export const WidgetNodeTypeSpacer = "spacer";
|
|
643
|
-
export const WidgetNodeTypeDivider = "divider";
|
|
644
|
-
export const WidgetNodeTypeForm = "form";
|
|
645
|
-
export const WidgetNodeTypeTitle = "title";
|
|
646
|
-
export const WidgetNodeTypeCaption = "caption";
|
|
647
|
-
export const WidgetNodeTypeLabel = "label";
|
|
648
|
-
export const WidgetNodeTypeTextarea = "textarea";
|
|
649
|
-
export const WidgetNodeTypeRadioGroup = "radio-group";
|
|
650
|
-
export const WidgetNodeTypeDatePicker = "date-picker";
|
|
651
|
-
export const WidgetNodeTypeIcon = "icon";
|
|
652
|
-
export const WidgetNodeTypeChart = "chart";
|
|
653
|
-
export const WidgetNodeTypeTransition = "transition";
|
|
654
|
-
export const WidgetNodeTypePlanList = "plan-list";
|
|
655
|
-
export const WidgetNodeTypeKeyValue = "key-value";
|
|
656
|
-
export const WidgetNodeTypeStatusBadge = "status-badge";
|
|
860
|
+
export const IntegrationGrantToken = "token";
|
|
861
|
+
export const CredentialScopePlatform = "platform";
|
|
862
|
+
/**
|
|
863
|
+
* CredentialScopeOrg: shared across all teams of an org. In the enum for
|
|
864
|
+
* end-to-end typing (connect-level pickers); connects with it are refused
|
|
865
|
+
* until the org domain lands (INF-795 Phase 2). Resolution order once
|
|
866
|
+
* live: agent > user > team > org > platform.
|
|
867
|
+
*/
|
|
868
|
+
export const CredentialScopeOrg = "org";
|
|
869
|
+
export const CredentialScopeTeam = "team";
|
|
870
|
+
export const CredentialScopeUser = "user";
|
|
871
|
+
export const CredentialScopeAgent = "agent";
|
|
657
872
|
export const NotificationChannelEmail = "email";
|
|
658
873
|
export const NotificationChannelSMS = "sms";
|
|
659
874
|
export const NotificationChannelPush = "push";
|
|
@@ -675,6 +890,7 @@ export const NotificationTypeInvoice = "invoice";
|
|
|
675
890
|
export const NotificationTypeSubscriptionCreated = "subscription_created";
|
|
676
891
|
export const NotificationTypeSubscriptionCredit = "subscription_credit";
|
|
677
892
|
export const NotificationTypeSubscriptionCanceled = "subscription_canceled";
|
|
893
|
+
export const NotificationTypeSubscriptionPaymentFailed = "subscription_payment_failed";
|
|
678
894
|
export const NotificationTypeSubscriptionTrialEnding = "subscription_trial_ending";
|
|
679
895
|
/**
|
|
680
896
|
* Account notifications
|
package/dist/utils.d.ts
CHANGED
|
@@ -15,3 +15,16 @@ export declare function parseStatus(status: number | string | undefined | null):
|
|
|
15
15
|
*/
|
|
16
16
|
export declare function isTerminalStatus(status: number | string | undefined | null): boolean;
|
|
17
17
|
export declare function isChatBusy(chat: ChatDTO | null | undefined): boolean;
|
|
18
|
+
/** A tool invocation gated on human approval, projected from the chat's pending interrupts. */
|
|
19
|
+
export type PendingApproval = {
|
|
20
|
+
interruptId: string;
|
|
21
|
+
toolInvocationId: string;
|
|
22
|
+
chatId: string;
|
|
23
|
+
toolName: string;
|
|
24
|
+
arguments: Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Tool approvals the chat is currently waiting on. Reads `chat.pending_interrupts`,
|
|
28
|
+
* which the API projects onto the chat, so no message scan is needed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function pendingApprovals(chat: ChatDTO | null | undefined): PendingApproval[];
|
package/dist/utils.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Status utilities for handling both int and string-based status values.
|
|
3
3
|
* Provides future compatibility when API migrates from int to string status.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { InterruptReasonToolApproval, InterruptStatusPending } from './types';
|
|
6
|
+
import { TaskStatusUnknown, TaskStatusReceived, TaskStatusQueued, TaskStatusDispatched, TaskStatusPreparing, TaskStatusServing, TaskStatusSettingUp, TaskStatusRunning, TaskStatusCancelling, TaskStatusUploading, TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, AgentRunStateWorking, AgentRunStateSubmitted, AgentRunStateInputRequired, ChatStatusBusy, ChatStatusAwaitingInput, } from './types';
|
|
6
7
|
/** Map string status names to TaskStatus values (for future string-based API) */
|
|
7
8
|
const STATUS_STRING_MAP = {
|
|
8
9
|
unknown: TaskStatusUnknown,
|
|
@@ -44,6 +45,45 @@ export function isTerminalStatus(status) {
|
|
|
44
45
|
return parsed === TaskStatusCompleted || parsed === TaskStatusFailed || parsed === TaskStatusCancelled;
|
|
45
46
|
}
|
|
46
47
|
export function isChatBusy(chat) {
|
|
47
|
-
const
|
|
48
|
-
|
|
48
|
+
const run = chat?.active_run;
|
|
49
|
+
if (run) {
|
|
50
|
+
return run.state === AgentRunStateWorking || run.state === AgentRunStateSubmitted || run.state === AgentRunStateInputRequired;
|
|
51
|
+
}
|
|
52
|
+
return chat?.status === ChatStatusBusy || chat?.status === ChatStatusAwaitingInput;
|
|
53
|
+
}
|
|
54
|
+
function parseApprovalMeta(interrupt) {
|
|
55
|
+
const meta = interrupt.meta;
|
|
56
|
+
if (!meta)
|
|
57
|
+
return {};
|
|
58
|
+
if (typeof meta === 'string') {
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(meta);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return meta;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Tool approvals the chat is currently waiting on. Reads `chat.pending_interrupts`,
|
|
70
|
+
* which the API projects onto the chat, so no message scan is needed.
|
|
71
|
+
*/
|
|
72
|
+
export function pendingApprovals(chat) {
|
|
73
|
+
const interrupts = chat?.pending_interrupts ?? [];
|
|
74
|
+
const out = [];
|
|
75
|
+
for (const interrupt of interrupts) {
|
|
76
|
+
if (interrupt.reason !== InterruptReasonToolApproval || interrupt.status !== InterruptStatusPending) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const meta = parseApprovalMeta(interrupt);
|
|
80
|
+
out.push({
|
|
81
|
+
interruptId: interrupt.id,
|
|
82
|
+
toolInvocationId: interrupt.resource_id ?? meta.tool_invocation_id ?? '',
|
|
83
|
+
chatId: interrupt.chat_id || chat?.id || '',
|
|
84
|
+
toolName: meta.tool_name ?? '',
|
|
85
|
+
arguments: meta.arguments ?? {},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
49
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inferencesh/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.48",
|
|
4
4
|
"description": "Official JavaScript/TypeScript SDK for inference.sh - Run AI models with a simple API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"./proxy/remix": {
|
|
31
31
|
"types": "./dist/proxy/remix.d.ts",
|
|
32
|
+
"inference-src": "./src/proxy/remix.ts",
|
|
32
33
|
"default": "./dist/proxy/remix.js"
|
|
33
34
|
},
|
|
34
35
|
"./proxy/svelte": {
|
|
@@ -46,21 +47,6 @@
|
|
|
46
47
|
"default": "./dist/api/files.js"
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build": "tsc",
|
|
51
|
-
"test": "jest --testPathIgnorePatterns=/integration\\.test\\.ts$ --testPathIgnorePatterns=\\.integration\\.test\\.ts$",
|
|
52
|
-
"test:integration": "jest --testPathPattern=integration --testTimeout=120000 --runInBand",
|
|
53
|
-
"test:all": "jest --testTimeout=120000 --runInBand",
|
|
54
|
-
"test:watch": "jest --watch --testPathIgnorePatterns=/integration\\.test\\.ts$ --testPathIgnorePatterns=\\.integration\\.test\\.ts$",
|
|
55
|
-
"test:coverage": "jest --coverage --testPathIgnorePatterns=/integration\\.test\\.ts$ --testPathIgnorePatterns=\\.integration\\.test\\.ts$",
|
|
56
|
-
"lint": "eslint src --ext .ts",
|
|
57
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
58
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
59
|
-
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
60
|
-
"clean": "rimraf dist coverage",
|
|
61
|
-
"prepublishOnly": "npm run clean && npm run build && npm test",
|
|
62
|
-
"example": "node examples/basic.js"
|
|
63
|
-
},
|
|
64
50
|
"keywords": [
|
|
65
51
|
"inference",
|
|
66
52
|
"ai",
|
|
@@ -94,21 +80,23 @@
|
|
|
94
80
|
},
|
|
95
81
|
"devDependencies": {
|
|
96
82
|
"@sveltejs/kit": "^2.60.1",
|
|
97
|
-
"svelte": "^5.55.7",
|
|
98
83
|
"@types/express": "^5.0.0",
|
|
99
84
|
"@types/jest": "^30.0.0",
|
|
100
85
|
"@types/node": "^26.1.1",
|
|
101
86
|
"@types/react": "^19.1.12",
|
|
87
|
+
"@eslint/js": "^9.39.5",
|
|
102
88
|
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
|
103
89
|
"@typescript-eslint/parser": "^8.65.0",
|
|
104
90
|
"eslint": "^9.32.0",
|
|
105
91
|
"eslint-config-prettier": "^10.1.8",
|
|
106
|
-
"
|
|
92
|
+
"globals": "^16.5.0",
|
|
93
|
+
"hono": "^4.13.1",
|
|
107
94
|
"jest": "^30.4.2",
|
|
108
95
|
"next": "^16.2.6",
|
|
109
96
|
"prettier": "^3.6.2",
|
|
110
97
|
"react": "^19.2.3",
|
|
111
98
|
"rimraf": "^6.0.1",
|
|
99
|
+
"svelte": "^5.55.7",
|
|
112
100
|
"ts-jest": "^29.2.5",
|
|
113
101
|
"typescript": "~6.0.3"
|
|
114
102
|
},
|
|
@@ -143,10 +131,18 @@
|
|
|
143
131
|
"LICENSE",
|
|
144
132
|
"CHANGELOG.md"
|
|
145
133
|
],
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
134
|
+
"scripts": {
|
|
135
|
+
"build": "tsc",
|
|
136
|
+
"test": "jest --testPathIgnorePatterns=/integration\\.test\\.ts$ --testPathIgnorePatterns=\\.integration\\.test\\.ts$",
|
|
137
|
+
"test:integration": "jest --testPathPattern=integration --testTimeout=120000 --runInBand",
|
|
138
|
+
"test:all": "jest --testTimeout=120000 --runInBand",
|
|
139
|
+
"test:watch": "jest --watch --testPathIgnorePatterns=/integration\\.test\\.ts$ --testPathIgnorePatterns=\\.integration\\.test\\.ts$",
|
|
140
|
+
"test:coverage": "jest --coverage --testPathIgnorePatterns=/integration\\.test\\.ts$ --testPathIgnorePatterns=\\.integration\\.test\\.ts$",
|
|
141
|
+
"lint": "eslint src",
|
|
142
|
+
"lint:fix": "eslint src --fix",
|
|
143
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
144
|
+
"format:check": "prettier --check \"src/**/*.ts\"",
|
|
145
|
+
"clean": "rimraf dist coverage",
|
|
146
|
+
"example": "node examples/basic.js"
|
|
151
147
|
}
|
|
152
|
-
}
|
|
148
|
+
}
|