@ibgib/web-gib 0.0.4 → 0.0.6
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/dist/api/commands/chat/tell-user.d.mts.map +1 -1
- package/dist/api/commands/chat/tell-user.mjs +1 -1
- package/dist/api/commands/chat/tell-user.mjs.map +1 -1
- package/dist/common/settings/settings-constants.d.mts.map +1 -1
- package/dist/common/settings/settings-constants.mjs.map +1 -1
- package/dist/helpers.d.mts +7 -0
- package/dist/helpers.d.mts.map +1 -1
- package/dist/helpers.mjs +25 -0
- package/dist/helpers.mjs.map +1 -1
- package/dist/helpers.web.d.mts +22 -0
- package/dist/helpers.web.d.mts.map +1 -1
- package/dist/helpers.web.mjs +22 -0
- package/dist/helpers.web.mjs.map +1 -1
- package/dist/witness/agent/agent-helpers.d.mts +81 -3
- package/dist/witness/agent/agent-helpers.d.mts.map +1 -1
- package/dist/witness/agent/agent-helpers.mjs +211 -2
- package/dist/witness/agent/agent-helpers.mjs.map +1 -1
- package/dist/witness/agent/agent-one-file.d.mts +1 -264
- package/dist/witness/agent/agent-one-file.d.mts.map +1 -1
- package/dist/witness/agent/agent-one-file.mjs +4 -242
- package/dist/witness/agent/agent-one-file.mjs.map +1 -1
- package/dist/witness/agent/agent-types.d.mts +189 -1
- package/dist/witness/agent/agent-types.d.mts.map +1 -1
- package/dist/witness/agent/agent-types.mjs +30 -1
- package/dist/witness/agent/agent-types.mjs.map +1 -1
- package/dist/witness/agent/agents-service-v1.d.mts +1 -1
- package/dist/witness/agent/agents-service-v1.d.mts.map +1 -1
- package/dist/witness/agent/agents-service-v1.mjs +1 -2
- package/dist/witness/agent/agents-service-v1.mjs.map +1 -1
- package/dist/witness/agent/gemini/agent-witness-gemini-v1.d.mts +4 -3
- package/dist/witness/agent/gemini/agent-witness-gemini-v1.d.mts.map +1 -1
- package/dist/witness/agent/gemini/agent-witness-gemini-v1.mjs +162 -88
- package/dist/witness/agent/gemini/agent-witness-gemini-v1.mjs.map +1 -1
- package/dist/witness/agent/gemini/gemini-agent-factory.d.mts +2 -1
- package/dist/witness/agent/gemini/gemini-agent-factory.d.mts.map +1 -1
- package/dist/witness/agent/gemini/gemini-agent-factory.mjs +1 -1
- package/dist/witness/agent/gemini/gemini-agent-factory.mjs.map +1 -1
- package/dist/witness/agent/gemini/gemini-helpers.d.mts +11 -4
- package/dist/witness/agent/gemini/gemini-helpers.d.mts.map +1 -1
- package/dist/witness/agent/gemini/gemini-helpers.mjs +7 -3
- package/dist/witness/agent/gemini/gemini-helpers.mjs.map +1 -1
- package/dist/witness/agent/gemini/gemini-types.d.mts +21 -13
- package/dist/witness/agent/gemini/gemini-types.d.mts.map +1 -1
- package/dist/witness/agent/gemini/gemini-types.mjs.map +1 -1
- package/package.json +2 -2
- package/src/api/commands/chat/tell-user.mts +1 -3
- package/src/common/settings/settings-constants.mts +4 -1
- package/src/helpers.mts +24 -0
- package/src/helpers.web.mts +22 -0
- package/src/witness/agent/agent-helpers.mts +243 -5
- package/src/witness/agent/agent-one-file.mts +8 -473
- package/src/witness/agent/agent-types.mts +228 -3
- package/src/witness/agent/agents-service-v1.mts +3 -2
- package/src/witness/agent/gemini/agent-witness-gemini-v1.mts +193 -96
- package/src/witness/agent/gemini/gemini-agent-factory.mts +2 -1
- package/src/witness/agent/gemini/gemini-helpers.mts +16 -6
- package/src/witness/agent/gemini/gemini-types.mts +39 -13
|
@@ -6,10 +6,235 @@ import { MetaspaceService } from '@ibgib/core-gib/dist/witness/space/metaspace/m
|
|
|
6
6
|
// import { GLOBAL_LOG_A_LOT } from '../../constants.mjs';
|
|
7
7
|
import { APIFunctionInfo } from '../../api/api-types.mjs';
|
|
8
8
|
import type { AgentWitness_V1 } from './agent-one-file.mjs';
|
|
9
|
-
import {
|
|
10
|
-
AgentWitnessAny, AgentWitnessData_V1, AgentWitnessRel8ns_V1,
|
|
11
|
-
} from './agent-one-file.mjs';
|
|
9
|
+
import { AgentWitnessAny, } from './agent-one-file.mjs';
|
|
12
10
|
import { GeminiModel } from './gemini/gemini-constants.mjs';
|
|
11
|
+
import { DEFAULT_DESCRIPTION_AGENT, DEFAULT_NAME_AGENT, DEFAULT_UUID_AGENT, TextSource } from './agent-constants.mjs';
|
|
12
|
+
import { AGENT_SPECIAL_IBGIB_TYPE_PRIMARYAGENT } from '../../agent-texts/primary-agent-texts.mjs';
|
|
13
|
+
import { ROOT_ADDR } from '@ibgib/ts-gib/dist/V1/constants.mjs';
|
|
14
|
+
import { WitnessData_V1, WitnessRel8ns_V1 } from '@ibgib/core-gib/dist/witness/witness-types.mjs';
|
|
15
|
+
import { SpaceId } from '@ibgib/core-gib/dist/witness/space/space-types.mjs';
|
|
16
|
+
import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
|
|
17
|
+
import { CommentIbGib_V1 } from '@ibgib/core-gib/dist/common/comment/comment-types.mjs';
|
|
18
|
+
import { PromptAPIResult_Gemini } from './gemini/gemini-types.mjs';
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export const DEFAULT_AGENT_DATA_V1: AgentWitnessData_V1 = {
|
|
22
|
+
version: '1',
|
|
23
|
+
uuid: DEFAULT_UUID_AGENT,
|
|
24
|
+
name: DEFAULT_NAME_AGENT,
|
|
25
|
+
description: DEFAULT_DESCRIPTION_AGENT,
|
|
26
|
+
classname: `AgentWitness_V1`,
|
|
27
|
+
icon: 'happy', // arbitrary
|
|
28
|
+
persistOptsAndResultIbGibs: false,
|
|
29
|
+
allowPrimitiveArgs: true,
|
|
30
|
+
catchAllErrors: true,
|
|
31
|
+
trace: false,
|
|
32
|
+
|
|
33
|
+
// agent-specific props
|
|
34
|
+
subSpaceId: '',
|
|
35
|
+
// purpose: '',
|
|
36
|
+
superSpaceId: '',
|
|
37
|
+
availableFunctionNameOrIds: [],
|
|
38
|
+
model: GeminiModel.GEMINI_2_0_FLASH,
|
|
39
|
+
// model: GeminiModel.GEMINI_1_5_PRO,
|
|
40
|
+
api: 'gemini',
|
|
41
|
+
type: AGENT_SPECIAL_IBGIB_TYPE_PRIMARYAGENT,
|
|
42
|
+
"@currentContextTjpAddr": ROOT_ADDR,
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* don't init with an empty obj. use undefined or factory_v1.firstGen blows up.
|
|
46
|
+
*/
|
|
47
|
+
export const DEFAULT_AGENT_REL8NS_V1: AgentWitnessRel8ns_V1 | undefined = undefined;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @interface AgentWitnessData - Data interface for the AgentWitness.
|
|
52
|
+
* @extends WitnessData_V1
|
|
53
|
+
*/
|
|
54
|
+
export interface AgentWitnessData_V1 extends WitnessData_V1 {
|
|
55
|
+
/**
|
|
56
|
+
* this id corresponds to what space the agent has access to as its own "internal" space.
|
|
57
|
+
*
|
|
58
|
+
* TODO: implement initialization code to create/get this space when the
|
|
59
|
+
* agent is created/initialized.
|
|
60
|
+
*
|
|
61
|
+
* TODO: implement an APIFunctionInfo for the agent
|
|
62
|
+
*
|
|
63
|
+
* it is possible that we will add access to other spaces in the future.
|
|
64
|
+
*/
|
|
65
|
+
subSpaceId: SpaceId;
|
|
66
|
+
/**
|
|
67
|
+
* The space in which the agent's ibgib itself is saved. This is often
|
|
68
|
+
* (always?) different than the super space in which the agent itself
|
|
69
|
+
* resides.
|
|
70
|
+
*/
|
|
71
|
+
superSpaceId: SpaceId;
|
|
72
|
+
/**
|
|
73
|
+
* nameOrId corresponding to the function info
|
|
74
|
+
*/
|
|
75
|
+
availableFunctionNameOrIds: string[];
|
|
76
|
+
/**
|
|
77
|
+
* @see {@link AgentAPI}
|
|
78
|
+
*/
|
|
79
|
+
api: AgentAPI;
|
|
80
|
+
/**
|
|
81
|
+
* @see {@link AgentModel}
|
|
82
|
+
*/
|
|
83
|
+
model: AgentModel;
|
|
84
|
+
/**
|
|
85
|
+
* A more fine-grained discriminator.
|
|
86
|
+
*/
|
|
87
|
+
type: string;
|
|
88
|
+
/**
|
|
89
|
+
* soft link to the current context ibgib. May be out of date, so should use
|
|
90
|
+
* get latest on the space (often can do this via metaspace with this
|
|
91
|
+
* agent's {@link superSpaceId}).
|
|
92
|
+
*
|
|
93
|
+
* This defaults to ib^gib (ROOT_ADDR), so if this is the value, then this
|
|
94
|
+
* has not been initialized yet and the agent needs to have their context
|
|
95
|
+
* set.
|
|
96
|
+
*/
|
|
97
|
+
"@currentContextTjpAddr": IbGibAddr; // string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @interface AgentWitnessRel8ns - Rel8ns interface for the AgentWitness.
|
|
102
|
+
* @extends IbGibRel8ns_V1
|
|
103
|
+
*/
|
|
104
|
+
export interface AgentWitnessRel8ns_V1 extends WitnessRel8ns_V1 {
|
|
105
|
+
/**
|
|
106
|
+
* @property chat - Relationships to comment ibgibs representing chat
|
|
107
|
+
* history for this agent.
|
|
108
|
+
*
|
|
109
|
+
* These are expected to be comment ibgibs with special additional metadata
|
|
110
|
+
* text in the ib that pertains to the agents {@link AgentWitness_V1}.
|
|
111
|
+
*
|
|
112
|
+
* @see {@link system}
|
|
113
|
+
*/
|
|
114
|
+
chat?: IbGibAddr[];
|
|
115
|
+
/**
|
|
116
|
+
* @property system - Relationships to comment ibgibs representing the
|
|
117
|
+
* system prompt.
|
|
118
|
+
*
|
|
119
|
+
* This is a Gemini-specific construct that I don't know if it exists in
|
|
120
|
+
* other APIs. But the intent is that these are comment ibgibs to be used in
|
|
121
|
+
* composing any meta text that is not part of a "chat" between one or more
|
|
122
|
+
* users and one or more models.
|
|
123
|
+
*
|
|
124
|
+
* These are expected to be comment ibgibs with special additional metadata
|
|
125
|
+
* text in the ib that pertains to the agents {@link AgentWitness_V1}.
|
|
126
|
+
*
|
|
127
|
+
* @see {@link system}
|
|
128
|
+
*/
|
|
129
|
+
system?: IbGibAddr[];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @interface AgentWitnessIbGib_V1 - Interface for an agent ibgib.
|
|
134
|
+
*
|
|
135
|
+
* @see {@link AgentWitness_V1}
|
|
136
|
+
*/
|
|
137
|
+
export interface AgentWitnessIbGib_V1 extends IbGib_V1<AgentWitnessData_V1, AgentWitnessRel8ns_V1> {
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface AddTextInfo {
|
|
141
|
+
/**
|
|
142
|
+
* @property text - raw comment text string to add
|
|
143
|
+
* @optional
|
|
144
|
+
*/
|
|
145
|
+
text?: string;
|
|
146
|
+
/**
|
|
147
|
+
* @optional @property commentIbGib - existing comment to add
|
|
148
|
+
*/
|
|
149
|
+
commentIbGib?: CommentIbGib_V1;
|
|
150
|
+
// textSrc: 'hardcoded' | 'human' | 'ai' | 'unknown';
|
|
151
|
+
textSrc: TextSource;
|
|
152
|
+
/**
|
|
153
|
+
* @property isSystem - If true, adds the text to the system prompt instead of chat history.
|
|
154
|
+
* @default false
|
|
155
|
+
*/
|
|
156
|
+
isSystem?: boolean;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @interface AddTextsOpts - Options for adding multiple text comments.
|
|
161
|
+
*/
|
|
162
|
+
export interface AddTextsOpts {
|
|
163
|
+
infos: AddTextInfo[];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface PromptOneOffOpts {
|
|
167
|
+
text: string;
|
|
168
|
+
/**
|
|
169
|
+
* ad hoc system instructions for the one off call.
|
|
170
|
+
*/
|
|
171
|
+
systemInstructions: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* an agent can only have one active context at any time.
|
|
176
|
+
*
|
|
177
|
+
* Really this is a timeline, so the key thing of this context ibgib is its
|
|
178
|
+
* temporal junction point (tjp).
|
|
179
|
+
*/
|
|
180
|
+
export interface SetActiveContextOpts {
|
|
181
|
+
contextIbGib: IbGib_V1;
|
|
182
|
+
/**
|
|
183
|
+
* for debug purposes
|
|
184
|
+
*/
|
|
185
|
+
loggingInfo?: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* When composing the prompt to send to the model, this is the information that
|
|
190
|
+
* we build up.
|
|
191
|
+
*/
|
|
192
|
+
export interface PromptInfo {
|
|
193
|
+
/**
|
|
194
|
+
* discriminator of what concrete info is contained in this object.
|
|
195
|
+
*/
|
|
196
|
+
api: AgentAPI;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @interface {@link PromptAPIResult} - shape of the result when calling into an
|
|
201
|
+
* api-specific model. In general, the api will either return a string or a
|
|
202
|
+
* function call request with optional arg(s)
|
|
203
|
+
* @see {@link AgentWitness_V1.callTextAPI}
|
|
204
|
+
*/
|
|
205
|
+
export type PromptAPIResult = | PromptAPIResult_Gemini;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* info object containing information in an agent ib schema.
|
|
209
|
+
*/
|
|
210
|
+
export interface AgentIbInfo {
|
|
211
|
+
/**
|
|
212
|
+
* should be {@link AGENT_ATOM}
|
|
213
|
+
*/
|
|
214
|
+
atom: string,
|
|
215
|
+
name: string,
|
|
216
|
+
uuid: string,
|
|
217
|
+
type: string,
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* information encoded in the addlMetadataText part of a comment ibgib that is
|
|
222
|
+
* part of an agent's chat/system text.
|
|
223
|
+
*
|
|
224
|
+
* notes: long name...
|
|
225
|
+
*/
|
|
226
|
+
export interface AddlMetadataTextForAgentTextInfo {
|
|
227
|
+
/**
|
|
228
|
+
* @see {@link AddTextInfo.textSrc}
|
|
229
|
+
*/
|
|
230
|
+
textSrc: TextSource;
|
|
231
|
+
timestampInTicks: number;
|
|
232
|
+
/**
|
|
233
|
+
* if there are additional underscore-delimited metadata texts, they will be here.
|
|
234
|
+
*/
|
|
235
|
+
other?: string[];
|
|
236
|
+
errorMsg?: string;
|
|
237
|
+
}
|
|
13
238
|
|
|
14
239
|
export type AgentModel =
|
|
15
240
|
| GeminiModel;
|
|
@@ -13,10 +13,11 @@ import { updateSpecialIndex } from "@ibgib/core-gib/dist/timeline/timeline-api.m
|
|
|
13
13
|
|
|
14
14
|
import { GLOBAL_LOG_A_LOT, HARDCODED_PROMPT_TAG_TEXT } from "../../constants.mjs";
|
|
15
15
|
import { getGlobalMetaspace_waitIfNeeded } from "../../helpers.mjs";
|
|
16
|
-
import { getAgents, getConcreteAgentFactory, getTag_Agents } from "./agent-helpers.mjs";
|
|
17
|
-
import { AddTextInfo,
|
|
16
|
+
import { getAgents, getConcreteAgentFactory, getTag_Agents, getAgentIb, parseAgentIb, taggifyForPrompt } from "./agent-helpers.mjs";
|
|
17
|
+
import { AddTextInfo, AgentWitnessData_V1, AgentWitnessIbGib_V1, } from "./agent-types.mjs";
|
|
18
18
|
import { AgentDtoToWitnessFunction, CreateNewAgentArg, CreateNewAgentResult } from "./agent-types.mjs";
|
|
19
19
|
import { AGENT_ATOM, AGENT_REL8N_NAME } from "./agent-constants.mjs";
|
|
20
|
+
import { AgentWitnessAny } from "./agent-one-file.mjs";
|
|
20
21
|
|
|
21
22
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
22
23
|
|