@sema-agent/client-core 0.98.0 → 0.100.0
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/CHANGELOG.md +376 -0
- package/README.md +61 -35
- package/dist/adapt/arms.js +120 -55
- package/dist/adapt/panelTasks.d.ts +3 -2
- package/dist/adapt/panelTasks.js +34 -11
- package/dist/adapt/textStream.d.ts +1 -1
- package/dist/adapt/textStream.js +51 -28
- package/dist/adapter/activeRunSelfHeal.d.ts +11 -3
- package/dist/adapter/activeRunSelfHeal.js +210 -294
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +176 -12
- package/dist/adapter/downstream/terminalToSdkResult.js +10 -0
- package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
- package/dist/adapter/downstream/wiringManifestView.js +1 -0
- package/dist/adapter/runStream.js +82 -40
- package/dist/adapter/types.d.ts +2 -0
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +7 -3
- package/dist/agentsWireCaps.js +133 -39
- package/dist/cloudConfigWireCaps.d.ts +10 -1
- package/dist/cloudConfigWireCaps.js +181 -65
- package/dist/compactionStatus.d.ts +34 -0
- package/dist/compactionStatus.js +196 -0
- package/dist/controlRouter.d.ts +4 -2
- package/dist/controlRouter.js +39 -51
- package/dist/coreValuePorts.d.ts +26 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/decideFailureNote.js +3 -3
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/detachWire.js +3 -2
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +153 -5
- package/dist/engineAgentPanelStore.d.ts +14 -4
- package/dist/engineAgentPanelStore.js +14 -0
- package/dist/engineCapReader.d.ts +2 -1
- package/dist/engineCapReader.js +7 -5
- package/dist/engineCapsCache.d.ts +8 -0
- package/dist/engineCapsCache.js +59 -6
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineErrorCodes.d.ts +11 -2
- package/dist/engineErrorCodes.js +11 -12
- package/dist/engineRowRef.js +4 -0
- package/dist/engineSessionMessages.d.ts +1 -0
- package/dist/engineSessionMessages.js +7 -1
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineToolDirectory.d.ts +3 -0
- package/dist/engineToolDirectory.js +4 -2
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +2 -1
- package/dist/env/uiLanguage.js +3 -2
- package/dist/eventLeg.d.ts +7 -5
- package/dist/eventLeg.js +68 -49
- package/dist/fileHistoryCaptureCapability.d.ts +2 -4
- package/dist/fileHistoryCaptureCapability.js +12 -22
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/frameBinding.d.ts +3 -0
- package/dist/frameBinding.js +12 -0
- package/dist/gateOutcome.js +16 -2
- package/dist/gateVocabulary.d.ts +8 -7
- package/dist/gateVocabulary.js +71 -73
- package/dist/generated/engineFactTables.d.ts +18 -1
- package/dist/generated/engineFactTables.js +56 -0
- package/dist/generated/engineNoticeTables.js +12 -3
- package/dist/generated/settingsSchemaFns.d.ts +18 -0
- package/dist/generated/settingsSchemaFns.js +70 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.js +162 -0
- package/dist/generated/settingsSchemaTables.d.ts +2 -0
- package/dist/generated/settingsSchemaTables.js +9 -0
- package/dist/generated/settingsSchemaTypes.d.ts +133 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +2 -1
- package/dist/hitl/allowRuleShadow.js +18 -15
- package/dist/hitl/approvalCardReasons.d.ts +3 -2
- package/dist/hitl/approvalCardReasons.js +29 -30
- package/dist/hitl/approvalHolds.d.ts +17 -0
- package/dist/hitl/approvalHolds.js +114 -29
- package/dist/hitl/askClassPair.d.ts +2 -2
- package/dist/hitl/askClassPair.js +16 -0
- package/dist/hitl/askGateWire.js +2 -1
- package/dist/hitl/askSettlementLine.d.ts +14 -4
- package/dist/hitl/askSettlementLine.js +67 -47
- package/dist/hitl/attributionLadder.d.ts +23 -0
- package/dist/hitl/attributionLadder.js +67 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +2 -1
- package/dist/hitl/automaticAnswerVerdict.js +8 -8
- package/dist/hitl/crashConvergedNotice.d.ts +5 -4
- package/dist/hitl/crashConvergedNotice.js +28 -41
- package/dist/hitl/decisionLedger.d.ts +55 -0
- package/dist/hitl/decisionLedger.js +156 -0
- package/dist/hitl/decisionRefusal.d.ts +1 -0
- package/dist/hitl/decisionRefusal.js +1 -1
- package/dist/hitl/decisionSend.d.ts +113 -0
- package/dist/hitl/decisionSend.js +579 -0
- package/dist/hitl/frameRouter.js +7 -8
- package/dist/hitl/hitlBridge.d.ts +1 -0
- package/dist/hitl/hitlBridge.js +21 -9
- package/dist/hitl/persistedRulesWire.d.ts +6 -5
- package/dist/hitl/persistedRulesWire.js +55 -73
- package/dist/hitl/planReviewWire.d.ts +5 -0
- package/dist/hitl/planReviewWire.js +53 -76
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +49 -9
- package/dist/hitl/sessionPolicyWire.d.ts +2 -1
- package/dist/hitl/sessionPolicyWire.js +23 -24
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +17 -5
- package/dist/hitl/toolApprovalWire.js +120 -147
- package/dist/hooksWireCaps.js +145 -56
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +110 -0
- package/dist/hostTurnSettings.js +692 -0
- package/dist/humanTurn.d.ts +15 -1
- package/dist/humanTurn.js +100 -12
- package/dist/humanTurnRead.d.ts +2 -0
- package/dist/humanTurnRead.js +22 -1
- package/dist/i18n/messages.en.d.ts +713 -0
- package/dist/i18n/messages.en.js +713 -0
- package/dist/i18n/messages.zh.js +854 -1
- package/dist/index.d.ts +45 -13
- package/dist/index.js +27 -9
- package/dist/inheritEnvCapability.d.ts +4 -2
- package/dist/inheritEnvCapability.js +12 -5
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +14 -16
- package/dist/injectionLaneNotice.d.ts +5 -0
- package/dist/injectionLaneNotice.js +46 -0
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +2 -1
- package/dist/liveModelCatalog.js +14 -8
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +42 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +3 -1
- package/dist/mcpProbeWire.js +5 -0
- package/dist/mcpReconnect.js +2 -2
- package/dist/mcpToolToggles.d.ts +6 -0
- package/dist/mcpToolToggles.js +46 -0
- package/dist/mcpWireCaps.d.ts +43 -3
- package/dist/mcpWireCaps.js +194 -59
- package/dist/mcpWireTransport.d.ts +4 -0
- package/dist/mcpWireTransport.js +18 -0
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +65 -0
- package/dist/modelCapabilityProbe.js +601 -0
- package/dist/modelIdentityResolvability.d.ts +5 -0
- package/dist/modelIdentityResolvability.js +49 -22
- package/dist/ownKey.d.ts +33 -0
- package/dist/ownKey.js +109 -0
- package/dist/panelReduce.d.ts +11 -1
- package/dist/panelReduce.js +95 -16
- package/dist/panelStateHolder.d.ts +1 -0
- package/dist/panelStateHolder.js +10 -1
- package/dist/permissionRuleIssue.d.ts +2 -1
- package/dist/permissionRuleIssue.js +23 -20
- package/dist/permissionRulesWriteCapability.d.ts +2 -1
- package/dist/permissionRulesWriteCapability.js +8 -6
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +220 -12
- package/dist/prepareRefusal.d.ts +8 -0
- package/dist/prepareRefusal.js +72 -0
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/request/taskRequest.d.ts +16 -10
- package/dist/request/taskRequest.js +195 -58
- package/dist/resumeRefusalCopy.d.ts +14 -9
- package/dist/resumeRefusalCopy.js +89 -144
- package/dist/retryStatus.d.ts +55 -0
- package/dist/retryStatus.js +155 -19
- package/dist/ruleRefusalSentence.d.ts +4 -0
- package/dist/ruleRefusalSentence.js +58 -0
- package/dist/sandboxWire.d.ts +2 -1
- package/dist/sandboxWire.js +55 -21
- package/dist/scenarioRefusal.d.ts +10 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/seam.d.ts +48 -9
- package/dist/seam.js +54 -5
- package/dist/seatContract.d.ts +272 -14
- package/dist/seatContract.js +711 -23
- package/dist/selfOrchestrationDenial.js +7 -19
- package/dist/sessionIdSegment.d.ts +6 -0
- package/dist/sessionIdSegment.js +24 -0
- package/dist/sessionMemoryStatus.js +6 -11
- package/dist/sessionPolicyCapability.d.ts +2 -1
- package/dist/sessionPolicyCapability.js +8 -6
- package/dist/settingsCredentialKeyPaths.d.ts +8 -0
- package/dist/settingsCredentialKeyPaths.js +219 -0
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -1
- package/dist/skillToolListsCapability.js +8 -6
- package/dist/skillsWireCaps.d.ts +0 -3
- package/dist/skillsWireCaps.js +1 -2
- package/dist/sseIdleTriage.js +3 -2
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagentContentStore.d.ts +4 -0
- package/dist/subagentContentStore.js +157 -27
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolRoster.d.ts +3 -2
- package/dist/toolRoster.js +21 -20
- package/dist/toolsFlagNames.d.ts +8 -0
- package/dist/toolsFlagNames.js +110 -0
- package/dist/turnFailurePresentation.d.ts +12 -1
- package/dist/turnFailurePresentation.js +220 -15
- package/dist/usageAnalytics.js +6 -11
- package/dist/userAttachmentEnvelope.d.ts +1 -0
- package/dist/userAttachmentEnvelope.js +37 -7
- package/dist/userAttachmentSeat.d.ts +21 -0
- package/dist/userAttachmentSeat.js +75 -0
- package/dist/userInvokedSkillsCapability.d.ts +11 -1
- package/dist/userInvokedSkillsCapability.js +31 -7
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +23 -1
- package/dist/wireFailureShape.js +2 -1
- package/dist/wireRefusalCopy.d.ts +62 -16
- package/dist/wireRefusalCopy.js +307 -148
- package/dist/workflowsJournalCapability.d.ts +2 -1
- package/dist/workflowsJournalCapability.js +8 -6
- package/docs/INTEGRATION-CLIENTS.md +951 -42
- package/package.json +5 -5
package/dist/humanTurn.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { UserAttachment } from '@sema-agent/sdk';
|
|
1
2
|
import type { ImageInput } from './imagesWireCaps.js';
|
|
2
3
|
import type { ImageVision } from './liveModelCatalog.js';
|
|
3
4
|
import { type UserAttachmentDescriptor } from './userAttachmentEnvelope.js';
|
|
5
|
+
import type { UserAttachmentSeatReading } from './userAttachmentSeat.js';
|
|
6
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
4
7
|
export interface HumanTurnRider {
|
|
5
8
|
readonly uuid: string;
|
|
6
9
|
readonly role: 'image_meta' | 'attachment' | 'skill_body' | (string & {});
|
|
@@ -34,6 +37,7 @@ export interface HumanTurnItem {
|
|
|
34
37
|
}
|
|
35
38
|
export interface HumanTurnCaps {
|
|
36
39
|
readonly vision?: ImageVision;
|
|
40
|
+
readonly userAttachments?: UserAttachmentSeatReading;
|
|
37
41
|
}
|
|
38
42
|
export interface HumanTurnInput {
|
|
39
43
|
readonly items: readonly HumanTurnItem[];
|
|
@@ -41,7 +45,7 @@ export interface HumanTurnInput {
|
|
|
41
45
|
readonly caps: HumanTurnCaps;
|
|
42
46
|
readonly otherBodyBytes?: number;
|
|
43
47
|
}
|
|
44
|
-
type EncoderShortfall = 'body_budget' | 'steer_admission' | 'vision_no' | '
|
|
48
|
+
type EncoderShortfall = 'body_budget' | 'steer_admission' | 'vision_no' | 'image_too_large' | 'seat_count' | 'seat_total' | 'lane_has_no_image_seat' | 'lane_has_no_attachment_id_seat';
|
|
45
49
|
export interface HumanTurnSharePart {
|
|
46
50
|
readonly kind: 'text' | 'image' | 'attachment_ref' | 'attachment_id' | 'rider_text' | 'non_text';
|
|
47
51
|
readonly ref?: string | number;
|
|
@@ -60,14 +64,23 @@ export interface HumanTurnDegraded {
|
|
|
60
64
|
readonly ref?: string | number;
|
|
61
65
|
readonly why: EncoderShortfall;
|
|
62
66
|
}
|
|
67
|
+
export interface HumanTurnNotice {
|
|
68
|
+
readonly uuid: string;
|
|
69
|
+
readonly kind: 'image';
|
|
70
|
+
readonly ref: string;
|
|
71
|
+
readonly why: 'vision_unknown';
|
|
72
|
+
}
|
|
63
73
|
export type HumanTurnEncoding = {
|
|
64
74
|
readonly ok: true;
|
|
65
75
|
readonly lane: 'objective';
|
|
66
76
|
readonly text: string;
|
|
67
77
|
readonly images: readonly ImageInput[];
|
|
68
78
|
readonly attachmentIds: readonly string[];
|
|
79
|
+
readonly userAttachments?: readonly UserAttachment[];
|
|
80
|
+
readonly userAttachmentOrdinals?: readonly string[];
|
|
69
81
|
readonly shares: readonly HumanTurnShare[];
|
|
70
82
|
readonly degraded: readonly HumanTurnDegraded[];
|
|
83
|
+
readonly notices?: readonly HumanTurnNotice[];
|
|
71
84
|
} | {
|
|
72
85
|
readonly ok: true;
|
|
73
86
|
readonly lane: 'steer';
|
|
@@ -86,6 +99,7 @@ export interface HumanTurnDelivered {
|
|
|
86
99
|
readonly full: readonly string[];
|
|
87
100
|
readonly partial: readonly string[];
|
|
88
101
|
}
|
|
102
|
+
export declare function imageSentOnUnknownVision(notices: readonly HumanTurnNotice[] | undefined, lang?: UiLanguage): string | undefined;
|
|
89
103
|
export declare function encodeHumanTurn(input: HumanTurnInput): HumanTurnEncoding;
|
|
90
104
|
export declare function deliveredUuidsOf(encoding: HumanTurnEncoding): HumanTurnDelivered;
|
|
91
105
|
export {};
|
package/dist/humanTurn.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CORE_MAX_PENDING_STEER_CHARS, CORE_MCP_IMAGE_MAX_BASE64 } from './generated/engineFactTables.js';
|
|
2
|
-
import { mintEnvelopeOf, mintReferenceOf } from './userAttachmentEnvelope.js';
|
|
1
|
+
import { CORE_MAX_PENDING_STEER_CHARS, CORE_MCP_IMAGE_MAX_BASE64, CORE_USER_ATTACHMENT_LABEL_MAX } from './generated/engineFactTables.js';
|
|
2
|
+
import { mintEnvelopeOf, mintReferenceOf, seatTextOf } from './userAttachmentEnvelope.js';
|
|
3
3
|
import { readEncodingShares, readHumanTurnInput } from './humanTurnRead.js';
|
|
4
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
4
5
|
const REQUEST_BODY_MAX_BYTES = 8 * 1024 * 1024;
|
|
5
6
|
const IMAGE_SEAT_MAX_COUNT = 20;
|
|
6
7
|
const IMAGE_SEAT_MAX_BASE64_CHARS_TOTAL = 6 * 1024 * 1024;
|
|
@@ -29,12 +30,14 @@ function utf8Length(s) {
|
|
|
29
30
|
return n;
|
|
30
31
|
}
|
|
31
32
|
const jsonBytes = (v) => utf8Length(JSON.stringify(v));
|
|
32
|
-
function bodyBytes(other, objective, images, ids) {
|
|
33
|
+
function bodyBytes(other, objective, images, ids, entries) {
|
|
33
34
|
const keys = [jsonBytes('objective') + 1 + jsonBytes(objective)];
|
|
34
35
|
if (images.length > 0)
|
|
35
36
|
keys.push(jsonBytes('images') + 1 + jsonBytes(images));
|
|
36
37
|
if (ids.length > 0)
|
|
37
38
|
keys.push(jsonBytes('attachmentIds') + 1 + jsonBytes(ids));
|
|
39
|
+
if (entries.length > 0)
|
|
40
|
+
keys.push(jsonBytes('userAttachments') + 1 + jsonBytes(entries));
|
|
38
41
|
const commas = other === 2 ? keys.length - 1 : keys.length;
|
|
39
42
|
return other + keys.reduce((a, b) => a + b, 0) + commas;
|
|
40
43
|
}
|
|
@@ -52,8 +55,27 @@ function steerRefusal(text) {
|
|
|
52
55
|
function textOf(p) {
|
|
53
56
|
if (p.form === 'reference')
|
|
54
57
|
return mintReferenceOf(p.a.d);
|
|
58
|
+
if (p.form === 'seat')
|
|
59
|
+
return '';
|
|
55
60
|
return mintEnvelopeOf(p.a.d, p.seated ? 'attached' : 'not-attached');
|
|
56
61
|
}
|
|
62
|
+
const digits = (n) => String(n).length;
|
|
63
|
+
function renderedUpperBound(text, startLine) {
|
|
64
|
+
const lines = text.split('\n').length;
|
|
65
|
+
return text.length + lines * (digits(startLine + lines - 1) + 1);
|
|
66
|
+
}
|
|
67
|
+
function seatEntryOf(a, maxRenderedTextChars) {
|
|
68
|
+
const text = seatTextOf(a.d);
|
|
69
|
+
if (text === undefined || !('path' in a.d))
|
|
70
|
+
return undefined;
|
|
71
|
+
const name = a.d.path;
|
|
72
|
+
if (name.length === 0 || name.length > CORE_USER_ATTACHMENT_LABEL_MAX)
|
|
73
|
+
return undefined;
|
|
74
|
+
const startLine = a.d.kind === 'text' ? a.d.startLine : 1;
|
|
75
|
+
if (renderedUpperBound(text, startLine) > maxRenderedTextChars)
|
|
76
|
+
return undefined;
|
|
77
|
+
return a.d.kind === 'text' ? { name, text, startLine } : { name, text };
|
|
78
|
+
}
|
|
57
79
|
function compose(items, placements) {
|
|
58
80
|
const perItem = items.map((it, i) => [...placements.filter((p) => p.item === i).map(textOf), it.text].filter((s) => s.length > 0).join('\n\n'));
|
|
59
81
|
return perItem.filter((s) => s.length > 0).join('\n');
|
|
@@ -76,7 +98,6 @@ const ENCODER_WHY_LIST = [
|
|
|
76
98
|
'body_budget',
|
|
77
99
|
'steer_admission',
|
|
78
100
|
'vision_no',
|
|
79
|
-
'vision_unknown',
|
|
80
101
|
'image_too_large',
|
|
81
102
|
'seat_count',
|
|
82
103
|
'seat_total',
|
|
@@ -101,7 +122,7 @@ function records(lane, items, pastedWhy, placements) {
|
|
|
101
122
|
for (const p of placements) {
|
|
102
123
|
if (p.item !== i)
|
|
103
124
|
continue;
|
|
104
|
-
push(i, p.form
|
|
125
|
+
push(i, p.form !== 'reference' ? { kind: 'attachment_ref', ref: p.a.uuid, status: 'full' } : { kind: 'attachment_ref', ref: p.a.uuid, status: 'none', why: lane === 'objective' ? 'body_budget' : 'steer_admission' });
|
|
105
126
|
if (p.a.pixels !== undefined) {
|
|
106
127
|
if (lane === 'steer')
|
|
107
128
|
push(i, { kind: 'image', ref: p.a.uuid, status: 'none', why: 'lane_has_no_image_seat' });
|
|
@@ -142,6 +163,32 @@ function sharesAndDegraded(items, recs) {
|
|
|
142
163
|
}
|
|
143
164
|
return { shares, degraded };
|
|
144
165
|
}
|
|
166
|
+
function noticesKey(v, items, placements) {
|
|
167
|
+
if (v.vision !== 'unknown')
|
|
168
|
+
return {};
|
|
169
|
+
const notices = [];
|
|
170
|
+
for (const p of placements) {
|
|
171
|
+
if (p.form === 'content' && p.seated && p.a.pixels !== undefined)
|
|
172
|
+
notices.push({ uuid: items[p.item].uuid, kind: 'image', ref: p.a.uuid, why: 'vision_unknown' });
|
|
173
|
+
}
|
|
174
|
+
return notices.length > 0 ? { notices } : {};
|
|
175
|
+
}
|
|
176
|
+
export function imageSentOnUnknownVision(notices, lang) {
|
|
177
|
+
let n = 0;
|
|
178
|
+
try {
|
|
179
|
+
if (!Array.isArray(notices))
|
|
180
|
+
return undefined;
|
|
181
|
+
for (const x of notices)
|
|
182
|
+
if (x !== null && typeof x === 'object' && x.why === 'vision_unknown')
|
|
183
|
+
n += 1;
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
if (n === 0)
|
|
189
|
+
return undefined;
|
|
190
|
+
return renderMessage(n === 1 ? msg('session.humanTurn.imageUnknownVision.one') : msg('session.humanTurn.imageUnknownVision.other', { count: n }), lang);
|
|
191
|
+
}
|
|
145
192
|
function encodeObjective(v) {
|
|
146
193
|
const { items } = v;
|
|
147
194
|
let count = 0;
|
|
@@ -161,10 +208,10 @@ function encodeObjective(v) {
|
|
|
161
208
|
const placements = [];
|
|
162
209
|
items.forEach((it, i) => {
|
|
163
210
|
for (const a of it.attachments) {
|
|
164
|
-
const p = { item: i, a, form: 'content', seated: false, seatWhy: undefined };
|
|
211
|
+
const p = { item: i, a, form: 'content', seated: false, seatWhy: undefined, entry: undefined };
|
|
165
212
|
if (a.pixels !== undefined) {
|
|
166
|
-
if (v.vision
|
|
167
|
-
p.seatWhy =
|
|
213
|
+
if (v.vision === 'no')
|
|
214
|
+
p.seatWhy = 'vision_no';
|
|
168
215
|
else {
|
|
169
216
|
p.seatWhy = seat(a.pixels.data.length);
|
|
170
217
|
p.seated = p.seatWhy === undefined;
|
|
@@ -173,21 +220,62 @@ function encodeObjective(v) {
|
|
|
173
220
|
placements.push(p);
|
|
174
221
|
}
|
|
175
222
|
});
|
|
223
|
+
if (v.seat !== undefined) {
|
|
224
|
+
let n = 0;
|
|
225
|
+
for (const p of placements) {
|
|
226
|
+
if (n >= v.seat.maxEntries)
|
|
227
|
+
break;
|
|
228
|
+
const entry = seatEntryOf(p.a, v.seat.maxRenderedTextChars);
|
|
229
|
+
if (entry === undefined)
|
|
230
|
+
continue;
|
|
231
|
+
p.form = 'seat';
|
|
232
|
+
p.entry = entry;
|
|
233
|
+
n += 1;
|
|
234
|
+
}
|
|
235
|
+
if (n > 0 && compose(items, placements).trim() === '') {
|
|
236
|
+
for (const p of placements) {
|
|
237
|
+
if (p.form === 'seat') {
|
|
238
|
+
p.form = 'content';
|
|
239
|
+
p.entry = undefined;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
176
244
|
const ids = items.flatMap((it) => it.attachmentIds);
|
|
177
245
|
for (;;) {
|
|
178
246
|
const text = compose(items, placements);
|
|
179
247
|
const images = seatedImages(items, pastedWhy, placements);
|
|
180
|
-
|
|
248
|
+
const seated = placements.filter((p) => p.form === 'seat');
|
|
249
|
+
const entries = seated.map((p) => p.entry);
|
|
250
|
+
if (bodyBytes(v.otherBodyBytes, text, images, ids, entries) <= REQUEST_BODY_MAX_BYTES) {
|
|
181
251
|
if (text.trim() === '')
|
|
182
252
|
return { ok: false, reason: 'empty' };
|
|
183
253
|
const { shares, degraded } = sharesAndDegraded(items, records('objective', items, pastedWhy, placements));
|
|
184
|
-
return {
|
|
254
|
+
return {
|
|
255
|
+
ok: true,
|
|
256
|
+
lane: 'objective',
|
|
257
|
+
text,
|
|
258
|
+
images,
|
|
259
|
+
attachmentIds: [...ids],
|
|
260
|
+
...(entries.length > 0 ? { userAttachments: entries, userAttachmentOrdinals: seated.map((p) => p.a.uuid) } : {}),
|
|
261
|
+
shares,
|
|
262
|
+
degraded,
|
|
263
|
+
...noticesKey(v, items, placements),
|
|
264
|
+
};
|
|
185
265
|
}
|
|
186
266
|
let pick = -1;
|
|
187
267
|
let pickCost = -1;
|
|
188
268
|
placements.forEach((p, k) => {
|
|
189
|
-
if (p.form
|
|
269
|
+
if (p.form === 'reference')
|
|
190
270
|
return;
|
|
271
|
+
if (p.form === 'seat') {
|
|
272
|
+
const cost = jsonBytes(p.entry) + 1;
|
|
273
|
+
if (cost >= pickCost) {
|
|
274
|
+
pick = k;
|
|
275
|
+
pickCost = cost;
|
|
276
|
+
}
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
191
279
|
const cost = jsonBytes(textOf(p)) + (p.seated && p.a.pixels !== undefined ? jsonBytes({ data: p.a.pixels.data, mimeType: p.a.pixels.mimeType }) : 0);
|
|
192
280
|
if (cost >= pickCost) {
|
|
193
281
|
pick = k;
|
|
@@ -204,7 +292,7 @@ function encodeSteer(v) {
|
|
|
204
292
|
const placements = [];
|
|
205
293
|
items.forEach((it, i) => {
|
|
206
294
|
for (const a of it.attachments)
|
|
207
|
-
placements.push({ item: i, a, form: 'content', seated: false, seatWhy: undefined });
|
|
295
|
+
placements.push({ item: i, a, form: 'content', seated: false, seatWhy: undefined, entry: undefined });
|
|
208
296
|
});
|
|
209
297
|
let text = compose(items, placements);
|
|
210
298
|
let refusal = steerRefusal(text);
|
package/dist/humanTurnRead.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ImageInput } from './imagesWireCaps.js';
|
|
|
2
2
|
import type { UserAttachmentDescriptor, UserAttachmentMcpResourcePart, UserAttachmentNotIncludedReason, UserAttachmentSource } from './userAttachmentEnvelope.js';
|
|
3
3
|
import type { HumanTurnAttachment, HumanTurnEncoding, HumanTurnInput, HumanTurnMissing } from './humanTurn.js';
|
|
4
4
|
import type { ImageVision } from './liveModelCatalog.js';
|
|
5
|
+
import { type UserAttachmentSeatLimits } from './userAttachmentSeat.js';
|
|
5
6
|
export interface CellView {
|
|
6
7
|
cellType: string | undefined;
|
|
7
8
|
source: string | undefined;
|
|
@@ -104,6 +105,7 @@ export interface ItemView {
|
|
|
104
105
|
export interface InputView {
|
|
105
106
|
lane: 'objective' | 'steer';
|
|
106
107
|
vision: ImageVision;
|
|
108
|
+
seat: UserAttachmentSeatLimits | undefined;
|
|
107
109
|
otherBodyBytes: number;
|
|
108
110
|
items: ItemView[];
|
|
109
111
|
}
|
package/dist/humanTurnRead.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { userAttachmentSeatAdmits } from './userAttachmentSeat.js';
|
|
1
2
|
const descriptorKindsAligned = true;
|
|
2
3
|
void descriptorKindsAligned;
|
|
3
4
|
const MALFORMED = Object.freeze({});
|
|
@@ -258,6 +259,25 @@ function readItem(x) {
|
|
|
258
259
|
}),
|
|
259
260
|
};
|
|
260
261
|
}
|
|
262
|
+
function seatLimitsOf(caps) {
|
|
263
|
+
try {
|
|
264
|
+
const reading = ownData(caps, 'userAttachments');
|
|
265
|
+
if (reading === undefined)
|
|
266
|
+
return undefined;
|
|
267
|
+
if (userAttachmentSeatAdmits(reading) !== 'yes')
|
|
268
|
+
return undefined;
|
|
269
|
+
const limits = ownData(reading, 'limits');
|
|
270
|
+
if (!isPlainObject(limits))
|
|
271
|
+
return undefined;
|
|
272
|
+
const maxEntries = ownData(limits, 'maxEntries');
|
|
273
|
+
const maxRenderedTextChars = ownData(limits, 'maxRenderedTextChars');
|
|
274
|
+
const ok = (n) => typeof n === 'number' && Number.isSafeInteger(n) && n >= 1;
|
|
275
|
+
return ok(maxEntries) && ok(maxRenderedTextChars) ? { maxEntries, maxRenderedTextChars } : undefined;
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
261
281
|
function readInputAny(x) {
|
|
262
282
|
if (!isPlainObject(x))
|
|
263
283
|
reject('malformed_input');
|
|
@@ -271,6 +291,7 @@ function readInputAny(x) {
|
|
|
271
291
|
const vision = ownData(caps, 'vision');
|
|
272
292
|
if (vision !== undefined && vision !== 'yes' && vision !== 'no' && vision !== 'unknown')
|
|
273
293
|
reject('malformed_input');
|
|
294
|
+
const seat = seatLimitsOf(caps);
|
|
274
295
|
let otherBodyBytes = 0;
|
|
275
296
|
if (lane === 'objective') {
|
|
276
297
|
const ob = ownData(o, 'otherBodyBytes');
|
|
@@ -316,7 +337,7 @@ function readInputAny(x) {
|
|
|
316
337
|
}
|
|
317
338
|
if (items.every((it) => it.text.length === 0 && it.images.length === 0 && it.attachments.length === 0 && it.attachmentIds.length === 0))
|
|
318
339
|
reject('empty');
|
|
319
|
-
return { lane: lane, vision: vision ?? 'unknown', otherBodyBytes, items };
|
|
340
|
+
return { lane: lane, vision: vision ?? 'unknown', seat, otherBodyBytes, items };
|
|
320
341
|
}
|
|
321
342
|
export function readHumanTurnInput(input) {
|
|
322
343
|
try {
|