modjules 0.1.1

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.
@@ -0,0 +1,799 @@
1
+ import { SelectOptions } from './activities/types.js';
2
+ import { ActivityStorage } from './storage/types.js';
3
+ /**
4
+ * A factory function that creates an ActivityStorage instance for a given session ID.
5
+ * @internal
6
+ */
7
+ export type StorageFactory = (sessionId: string) => ActivityStorage;
8
+ /**
9
+ * Configuration options for the Jules SDK client.
10
+ *
11
+ * @example
12
+ * import { Jules } from 'modjules';
13
+ *
14
+ * const jules = Jules({
15
+ * apiKey: 'YOUR_API_KEY',
16
+ * config: {
17
+ * requestTimeoutMs: 60000, // 1 minute
18
+ * }
19
+ * });
20
+ */
21
+ export interface JulesOptions {
22
+ /**
23
+ * The API key used for authentication.
24
+ * If not provided, the SDK will attempt to read it from the JULES_API_KEY environment variable.
25
+ * Authenticates requests via the `X-Goog-Api-Key` header.
26
+ */
27
+ apiKey?: string;
28
+ /**
29
+ * The base URL for the Jules API.
30
+ * @default 'https://jules.googleapis.com/v1alpha'
31
+ */
32
+ baseUrl?: string;
33
+ /**
34
+ * (Internal) A factory for creating storage instances.
35
+ * This is used to inject platform-specific storage implementations (Node vs. Browser).
36
+ * @internal
37
+ */
38
+ storageFactory?: StorageFactory;
39
+ /**
40
+ * (Internal) The platform implementation.
41
+ * This is used to inject platform-specific functionality (Node vs. Browser).
42
+ * @internal
43
+ */
44
+ platform?: any;
45
+ /**
46
+ * Advanced operational parameters for the SDK.
47
+ */
48
+ config?: {
49
+ /**
50
+ * The interval in milliseconds to poll for session and activity updates.
51
+ * @default 5000
52
+ */
53
+ pollingIntervalMs?: number;
54
+ /**
55
+ * The timeout in milliseconds for individual HTTP requests to the Jules API.
56
+ * @default 30000
57
+ */
58
+ requestTimeoutMs?: number;
59
+ };
60
+ }
61
+ /**
62
+ * Ergonomic definition for specifying a source context when creating a session or run.
63
+ * This simplifies the process of targeting a specific GitHub repository and branch.
64
+ *
65
+ * @example
66
+ * const sourceInput: SourceInput = {
67
+ * github: 'my-org/my-repo',
68
+ * branch: 'main'
69
+ * };
70
+ */
71
+ export interface SourceInput {
72
+ /**
73
+ * The GitHub repository identifier in the format 'owner/repo'.
74
+ * The SDK will resolve this to the full source name (e.g., 'sources/github/owner/repo').
75
+ */
76
+ github: string;
77
+ /**
78
+ * The name of the branch to start the session from.
79
+ * Maps to `sourceContext.githubRepoContext.startingBranch` in the REST API.
80
+ */
81
+ branch: string;
82
+ }
83
+ /**
84
+ * Configuration options for starting a new session or run.
85
+ * This is the primary input for `jules.run()` and `jules.session()`.
86
+ *
87
+ * @example
88
+ * const config: SessionConfig = {
89
+ * prompt: "Fix the login button bug.",
90
+ * source: { github: 'my-org/my-repo', branch: 'main' },
91
+ * requireApproval: false
92
+ * };
93
+ */
94
+ export interface SessionConfig {
95
+ /**
96
+ * The initial instruction or task description for the agent.
97
+ * Required. Maps to `prompt` in the REST API `POST /sessions` payload.
98
+ */
99
+ prompt: string;
100
+ /**
101
+ * The source code context for the session.
102
+ * Required. The SDK constructs the `sourceContext` payload from this input.
103
+ */
104
+ source: SourceInput;
105
+ /**
106
+ * Optional title for the session. If not provided, the system will generate one.
107
+ * Maps to `title` in the REST API.
108
+ */
109
+ title?: string;
110
+ /**
111
+ * If true, the agent will pause and wait for explicit approval (via `session.approve()`)
112
+ * before executing any generated plan.
113
+ *
114
+ * @default false for `jules.run()`
115
+ * @default true for `jules.session()`
116
+ */
117
+ requireApproval?: boolean;
118
+ /**
119
+ * If true, the agent will automatically create a Pull Request when the task is completed.
120
+ * Maps to `automationMode: AUTO_CREATE_PR` in the REST API.
121
+ * If false, maps to `AUTOMATION_MODE_UNSPECIFIED`.
122
+ *
123
+ * @default true for `jules.run()`
124
+ */
125
+ autoPr?: boolean;
126
+ }
127
+ /**
128
+ * Represents the details of a GitHub repository connected to Jules.
129
+ * Maps to the `GitHubRepo` message in the REST API.
130
+ */
131
+ export interface GitHubRepo {
132
+ owner: string;
133
+ repo: string;
134
+ isPrivate: boolean;
135
+ }
136
+ /**
137
+ * An input source of data for a session (e.g., a GitHub repository).
138
+ * This is a discriminated union based on the `type` property.
139
+ * Maps to the `Source` resource in the REST API.
140
+ *
141
+ * @example
142
+ * async (source: Source) => {
143
+ * if (source.type === 'githubRepo') {
144
+ * console.log(source.githubRepo.owner);
145
+ * }
146
+ * }
147
+ */
148
+ export type Source = {
149
+ /**
150
+ * The full resource name (e.g., "sources/github/owner/repo").
151
+ */
152
+ name: string;
153
+ /**
154
+ * The short identifier of the source (e.g., "github/owner/repo").
155
+ */
156
+ id: string;
157
+ } & {
158
+ type: 'githubRepo';
159
+ githubRepo: GitHubRepo;
160
+ };
161
+ /**
162
+ * Represents the possible states of a session.
163
+ * Maps to the `State` enum in the REST API `Session` resource.
164
+ */
165
+ export type SessionState = 'unspecified' | 'queued' | 'planning'
166
+ /** The agent is waiting for plan approval. Call `session.approve()`. */
167
+ | 'awaitingPlanApproval' | 'awaitingUserFeedback' | 'inProgress' | 'paused' | 'failed' | 'completed';
168
+ /**
169
+ * The entity that an activity originates from.
170
+ */
171
+ export type Origin = 'user' | 'agent' | 'system';
172
+ /**
173
+ * A pull request created by the session.
174
+ * Maps to the `PullRequest` message in the REST API.
175
+ */
176
+ export interface PullRequest {
177
+ url: string;
178
+ title: string;
179
+ description: string;
180
+ }
181
+ /**
182
+ * An output of a session, such as a pull request.
183
+ * This is a discriminated union based on the `type` property.
184
+ * Maps to the `SessionOutput` message in the REST API.
185
+ *
186
+ * @example
187
+ * (output: SessionOutput) => {
188
+ * if (output.type === 'pullRequest') {
189
+ * console.log('PR URL:', output.pullRequest.url);
190
+ * }
191
+ * }
192
+ */
193
+ export type SessionOutput = {
194
+ type: 'pullRequest';
195
+ pullRequest: PullRequest;
196
+ };
197
+ /**
198
+ * Represents the context used when the session was created.
199
+ * Maps to the `SourceContext` message in the REST API.
200
+ */
201
+ export interface SourceContext {
202
+ /**
203
+ * The name of the source (e.g., "sources/github/owner/repo").
204
+ */
205
+ source: string;
206
+ /**
207
+ * Context specific to GitHub repos.
208
+ */
209
+ githubRepoContext?: {
210
+ startingBranch: string;
211
+ };
212
+ }
213
+ /**
214
+ * The underlying data structure representing a Session resource from the REST API.
215
+ * The SDK enhances this with helper methods in the `SessionClient`.
216
+ */
217
+ export interface SessionResource {
218
+ /**
219
+ * The full resource name (e.g., "sessions/314159...").
220
+ */
221
+ name: string;
222
+ /**
223
+ * The unique ID of the session.
224
+ */
225
+ id: string;
226
+ prompt: string;
227
+ sourceContext: SourceContext;
228
+ title: string;
229
+ /**
230
+ * The time the session was created (RFC 3339 timestamp).
231
+ */
232
+ createTime: string;
233
+ /**
234
+ * The time the session was last updated (RFC 3339 timestamp).
235
+ */
236
+ updateTime: string;
237
+ /**
238
+ * The current state of the session.
239
+ */
240
+ state: SessionState;
241
+ /**
242
+ * The URL to view the session in the Jules web app.
243
+ */
244
+ url: string;
245
+ /**
246
+ * The outputs of the session, if any.
247
+ */
248
+ outputs: SessionOutput[];
249
+ }
250
+ /**
251
+ * A single step within an agent's plan.
252
+ * Maps to the `PlanStep` message in the REST API.
253
+ */
254
+ export interface PlanStep {
255
+ id: string;
256
+ title: string;
257
+ description?: string;
258
+ index: number;
259
+ }
260
+ /**
261
+ * A sequence of steps that the agent will take to complete the task.
262
+ * Maps to the `Plan` message in the REST API.
263
+ */
264
+ export interface Plan {
265
+ id: string;
266
+ steps: PlanStep[];
267
+ createTime: string;
268
+ }
269
+ /**
270
+ * A patch in Git's unidiff format.
271
+ * Maps to the `GitPatch` message in the REST API.
272
+ */
273
+ export interface GitPatch {
274
+ /**
275
+ * The patch content.
276
+ */
277
+ unidiffPatch: string;
278
+ /**
279
+ * The base commit id the patch should be applied to.
280
+ */
281
+ baseCommitId: string;
282
+ /**
283
+ * A suggested commit message for the.
284
+ */
285
+ suggestedCommitMessage: string;
286
+ }
287
+ /**
288
+ * A set of changes to be applied to a source.
289
+ * Maps to the `ChangeSet` message in the REST API.
290
+ */
291
+ export interface ChangeSet {
292
+ source: string;
293
+ gitPatch: GitPatch;
294
+ }
295
+ /**
296
+ * A media output (e.g., an image) with a helper method to save the data.
297
+ * This is an SDK-specific enhancement.
298
+ */
299
+ export interface MediaArtifact {
300
+ readonly type: 'media';
301
+ /**
302
+ * The base64-encoded media data.
303
+ */
304
+ readonly data: string;
305
+ /**
306
+ * The format of the media (e.g., 'image/png').
307
+ */
308
+ readonly format: string;
309
+ /**
310
+ * Saves the media data to a file.
311
+ * This method is only available in Node.js environments.
312
+ *
313
+ * @param filepath The path to save the file to.
314
+ * @throws {Error} If called in a non-Node.js environment.
315
+ *
316
+ * @example
317
+ * if (artifact.type === 'media' && artifact.format.startsWith('image/')) {
318
+ * await artifact.save('./screenshot.png');
319
+ * }
320
+ */
321
+ save(filepath: string): Promise<void>;
322
+ /**
323
+ * Creates a blob URL for the media data.
324
+ * This works in both Node.js and browser environments.
325
+ *
326
+ * @returns A URL string that can be used to display or download the media.
327
+ *
328
+ * @example
329
+ * if (artifact.type === 'media') {
330
+ * const url = artifact.toUrl();
331
+ * // Browser: <img src={url} />
332
+ * // Node: console.log('Media URL:', url);
333
+ * }
334
+ */
335
+ toUrl(): string;
336
+ }
337
+ /**
338
+ * Output from a bash command execution, with a helper method to format the output.
339
+ * This is an SDK-specific enhancement.
340
+ */
341
+ export interface BashArtifact {
342
+ readonly type: 'bashOutput';
343
+ readonly command: string;
344
+ readonly stdout: string;
345
+ readonly stderr: string;
346
+ readonly exitCode: number | null;
347
+ /**
348
+ * Returns a cleanly formatted string combining the command, output, and exit code.
349
+ *
350
+ * @example
351
+ * if (artifact.type === 'bashOutput') {
352
+ * console.log(artifact.toString());
353
+ * }
354
+ */
355
+ toString(): string;
356
+ }
357
+ /**
358
+ * A single unit of data produced by an activity, enhanced with SDK helper methods.
359
+ * This is a discriminated union based on the `type` property.
360
+ * Maps to the `Artifact` resource in the REST API.
361
+ *
362
+ * @example
363
+ * (artifact: Artifact) => {
364
+ * if (artifact.type === 'changeSet') {
365
+ * console.log(artifact.changeSet.gitPatch.suggestedCommitMessage);
366
+ * }
367
+ * }
368
+ */
369
+ export type Artifact = {
370
+ type: 'changeSet';
371
+ changeSet: ChangeSet;
372
+ } | MediaArtifact | BashArtifact;
373
+ export interface RestChangeSetArtifact {
374
+ changeSet: ChangeSet;
375
+ }
376
+ export interface RestMediaArtifact {
377
+ media: {
378
+ data: string;
379
+ format: string;
380
+ };
381
+ }
382
+ export interface RestBashOutputArtifact {
383
+ bashOutput: {
384
+ command: string;
385
+ stdout: string;
386
+ stderr: string;
387
+ exitCode: number | null;
388
+ };
389
+ }
390
+ export type RestArtifact = RestChangeSetArtifact | RestMediaArtifact | RestBashOutputArtifact;
391
+ /**
392
+ * Base structure for all activities.
393
+ */
394
+ interface BaseActivity {
395
+ /**
396
+ * The full resource name (e.g., "sessions/{session}/activities/{activity}").
397
+ */
398
+ name: string;
399
+ id: string;
400
+ /**
401
+ * The time at which this activity was created (RFC 3339 timestamp).
402
+ */
403
+ createTime: string;
404
+ /**
405
+ * The entity that this activity originated from.
406
+ */
407
+ originator: 'user' | 'agent' | 'system';
408
+ /**
409
+ * The artifacts produced by this activity.
410
+ */
411
+ artifacts: Artifact[];
412
+ }
413
+ /**
414
+ * An activity representing a message from the agent.
415
+ */
416
+ export interface ActivityAgentMessaged extends BaseActivity {
417
+ type: 'agentMessaged';
418
+ /**
419
+ * The message the agent posted.
420
+ */
421
+ message: string;
422
+ }
423
+ /**
424
+ * An activity representing a message from the user.
425
+ */
426
+ export interface ActivityUserMessaged extends BaseActivity {
427
+ type: 'userMessaged';
428
+ /**
429
+ * The message the user posted.
430
+ */
431
+ message: string;
432
+ }
433
+ /**
434
+ * An activity representing a newly generated plan.
435
+ */
436
+ export interface ActivityPlanGenerated extends BaseActivity {
437
+ type: 'planGenerated';
438
+ /**
439
+ * The plan that was generated.
440
+ */
441
+ plan: Plan;
442
+ }
443
+ /**
444
+ * An activity representing the approval of a plan.
445
+ */
446
+ export interface ActivityPlanApproved extends BaseActivity {
447
+ type: 'planApproved';
448
+ /**
449
+ * The ID of the plan that was approved.
450
+ */
451
+ planId: string;
452
+ }
453
+ /**
454
+ * An activity representing a progress update from the agent.
455
+ */
456
+ export interface ActivityProgressUpdated extends BaseActivity {
457
+ type: 'progressUpdated';
458
+ /**
459
+ * The title of the progress update.
460
+ */
461
+ title: string;
462
+ /**
463
+ * The description of the progress update.
464
+ */
465
+ description: string;
466
+ }
467
+ /**
468
+ * An activity signifying the successful completion of a session.
469
+ */
470
+ export interface ActivitySessionCompleted extends BaseActivity {
471
+ type: 'sessionCompleted';
472
+ }
473
+ /**
474
+ * An activity signifying the failure of a session.
475
+ */
476
+ export interface ActivitySessionFailed extends BaseActivity {
477
+ type: 'sessionFailed';
478
+ /**
479
+ * The reason the session failed.
480
+ */
481
+ reason: string;
482
+ }
483
+ /**
484
+ * A single event or unit of work within a session.
485
+ * This discriminated union represents all possible activities streamed by the SDK.
486
+ * Maps to the `Activity` resource in the REST API.
487
+ *
488
+ * @example
489
+ * (activity: Activity) => {
490
+ * switch (activity.type) {
491
+ * case 'planGenerated':
492
+ * console.log('Plan:', activity.plan.steps.map(s => s.title));
493
+ * break;
494
+ * case 'agentMessaged':
495
+ * console.log('Agent says:', activity.message);
496
+ * break;
497
+ * }
498
+ * }
499
+ */
500
+ export type Activity = ActivityAgentMessaged | ActivityUserMessaged | ActivityPlanGenerated | ActivityPlanApproved | ActivityProgressUpdated | ActivitySessionCompleted | ActivitySessionFailed;
501
+ /**
502
+ * The final outcome of a completed session or run.
503
+ * This is derived from the final SessionResource state.
504
+ *
505
+ * @example
506
+ * (outcome: Outcome) => {
507
+ * if (outcome.state === 'completed' && outcome.pullRequest) {
508
+ * console.log(`Success! PR: ${outcome.pullRequest.url}`);
509
+ * }
510
+ * }
511
+ */
512
+ export interface Outcome {
513
+ sessionId: string;
514
+ title: string;
515
+ state: 'completed' | 'failed';
516
+ /**
517
+ * The primary Pull Request created by the session, if applicable.
518
+ */
519
+ pullRequest?: PullRequest;
520
+ /**
521
+ * All outputs generated by the session.
522
+ */
523
+ outputs: SessionOutput[];
524
+ }
525
+ /**
526
+ * Represents a Jules Session in automated mode, initiated by `jules.run()`.
527
+ *
528
+ * It provides methods for real-time observation and retrieving the final outcome.
529
+ */
530
+ export interface AutomatedSession {
531
+ /**
532
+ * The unique ID of the session.
533
+ */
534
+ readonly id: string;
535
+ /**
536
+ * Provides a real-time stream of activities as the automated run progresses.
537
+ * This uses an Async Iterator, making it easy to consume events as they happen.
538
+ *
539
+ * @example
540
+ * const run = await jules.run({ ... });
541
+ * for await (const activity of run.stream()) {
542
+ * console.log(`[${activity.type}]`);
543
+ * }
544
+ */
545
+ stream(): AsyncIterable<Activity>;
546
+ /**
547
+ * Waits for the session to complete and returns the final outcome.
548
+ *
549
+ * @example
550
+ * const run = await jules.run({ ... });
551
+ * const outcome = await run.result();
552
+ */
553
+ result(): Promise<Outcome>;
554
+ }
555
+ /**
556
+ * Options for streaming activities, such as filtering.
557
+ * This is a forward declaration; the actual type is in `streaming.ts`
558
+ * to avoid circular dependencies.
559
+ * @internal
560
+ */
561
+ export type StreamActivitiesOptions = {
562
+ exclude?: {
563
+ originator: Origin;
564
+ };
565
+ };
566
+ /**
567
+ * Represents an active, interactive session with the Jules agent.
568
+ * This is the primary interface for managing the lifecycle of an interactive session.
569
+ */
570
+ export interface SessionClient {
571
+ /**
572
+ * The unique ID of the session.
573
+ */
574
+ readonly id: string;
575
+ /**
576
+ * COLD STREAM: Yields all known past activities from local storage.
577
+ * Ends immediately after yielding the last known activity.
578
+ * Does NOT open a network connection.
579
+ */
580
+ history(): AsyncIterable<Activity>;
581
+ /**
582
+ * HOT STREAM: Yields ONLY future activities as they arrive from the network.
583
+ * Blocks indefinitely.
584
+ */
585
+ updates(): AsyncIterable<Activity>;
586
+ /**
587
+ * LOCAL QUERY: Performs rich filtering against local storage only.
588
+ * Fast, but might be incomplete if not synced.
589
+ */
590
+ select(options?: SelectOptions): Promise<Activity[]>;
591
+ /**
592
+ * Provides a real-time stream of activities for the session.
593
+ * This uses an Async Iterator to abstract the polling of the ListActivities endpoint.
594
+ *
595
+ * @param options Options to control the stream, such as filters.
596
+ * @example
597
+ * // Filter out activities originated by the user
598
+ * for await (const activity of session.stream({ exclude: { originator: 'user' } })) {
599
+ * console.log(activity.type);
600
+ * }
601
+ */
602
+ stream(options?: StreamActivitiesOptions): AsyncIterable<Activity>;
603
+ /**
604
+ * Approves the currently pending plan.
605
+ * Only valid if the session state is `awaitingPlanApproval`.
606
+ *
607
+ * @example
608
+ * await session.waitFor('awaitingPlanApproval');
609
+ * await session.approve();
610
+ */
611
+ approve(): Promise<void>;
612
+ /**
613
+ * Sends a message (prompt) to the agent in the context of the current session.
614
+ * This is a fire-and-forget operation. To see the response, use `stream()` or `ask()`.
615
+ *
616
+ * @param prompt The message to send.
617
+ * @example
618
+ * await session.send("Can you start working on the first step?");
619
+ */
620
+ send(prompt: string): Promise<void>;
621
+ /**
622
+ * Sends a message to the agent and waits specifically for the agent's immediate reply.
623
+ * This provides a convenient request/response flow for conversational interactions.
624
+ *
625
+ * @param prompt The message to send.
626
+ * @returns The agent's reply activity.
627
+ * @example
628
+ * const reply = await session.ask("What is the status of the plan?");
629
+ * console.log(reply.message);
630
+ */
631
+ ask(prompt: string): Promise<ActivityAgentMessaged>;
632
+ /**
633
+ * Waits for the session to reach a terminal state (completed or failed) and returns the result.
634
+ *
635
+ * @returns The final outcome of the session.
636
+ * @example
637
+ * const outcome = await session.result();
638
+ * console.log(`Session finished with state: ${outcome.state}`);
639
+ */
640
+ result(): Promise<Outcome>;
641
+ /**
642
+ * Pauses execution and waits until the session reaches a specific state.
643
+ *
644
+ * @param state The target state to wait for.
645
+ * @example
646
+ * console.log('Waiting for the agent to finish planning...');
647
+ * await session.waitFor('awaitingPlanApproval');
648
+ * console.log('Plan is ready for review.');
649
+ */
650
+ waitFor(state: SessionState): Promise<void>;
651
+ /**
652
+ * Retrieves the latest state of the underlying session resource from the API.
653
+ *
654
+ * @returns The latest session data.
655
+ * @example
656
+ * const sessionInfo = await session.info();
657
+ * console.log(`Current state: ${sessionInfo.state}`);
658
+ */
659
+ info(): Promise<SessionResource>;
660
+ }
661
+ /**
662
+ * Interface for managing and locating connected sources.
663
+ * Accessed via `jules.sources`.
664
+ */
665
+ export interface SourceManager {
666
+ /**
667
+ * Iterates over all connected sources.
668
+ * Uses an Async Iterator to abstract API pagination.
669
+ *
670
+ * @example
671
+ * for await (const source of jules.sources()) {
672
+ * if (source.type === 'githubRepo') {
673
+ * console.log(`Found repo: ${source.githubRepo.owner}/${source.githubRepo.repo}`);
674
+ * }
675
+ * }
676
+ */
677
+ (): AsyncIterable<Source>;
678
+ /**
679
+ * Locates a specific source based on ergonomic filters.
680
+ *
681
+ * @param filter The filter criteria (e.g., { github: 'owner/repo' }).
682
+ * @returns The matching Source or undefined if not found.
683
+ * @example
684
+ * const myRepo = await jules.sources.get({ github: 'my-org/my-project' });
685
+ */
686
+ get(filter: {
687
+ github: string;
688
+ }): Promise<Source | undefined>;
689
+ }
690
+ /**
691
+ * The main client interface for interacting with the Jules API.
692
+ */
693
+ export interface JulesClient {
694
+ /**
695
+ * Executes a task in automated mode.
696
+ * This is a high-level abstraction for "fire-and-forget" tasks.
697
+ *
698
+ * @param config The configuration for the run.
699
+ * @returns A `AutomatedSession` object, which is an enhanced Promise that resolves to the final outcome.
700
+ *
701
+ * @example
702
+ * const run = await jules.run({
703
+ * prompt: "Fix the bug described in issue #123",
704
+ * source: { github: 'my-org/my-project', branch: 'main' }
705
+ * });
706
+ * // The session is now running in the background.
707
+ * // You can optionally wait for the result:
708
+ * // const outcome = await run.result();
709
+ */
710
+ run(config: SessionConfig): Promise<AutomatedSession>;
711
+ /**
712
+ * Creates a new interactive session for workflows requiring human oversight.
713
+ *
714
+ * @param config The configuration for the session.
715
+ * @returns A Promise resolving to the interactive `SessionClient`.
716
+ *
717
+ * @example
718
+ * const session = await jules.session({
719
+ * prompt: "Let's refactor the authentication module.",
720
+ * source: { github: 'my-org/my-project', branch: 'develop' }
721
+ * });
722
+ */
723
+ session(config: SessionConfig): Promise<SessionClient>;
724
+ /**
725
+ * Rehydrates an existing session from its ID, allowing you to resume interaction.
726
+ *
727
+ * @param sessionId The ID of the existing session.
728
+ * @returns The interactive `SessionClient`.
729
+ *
730
+ * @example
731
+ * const session = jules.session('EXISTING_SESSION_ID');
732
+ * // now you can interact with it
733
+ * const info = await session.info();
734
+ */
735
+ session(sessionId: string): SessionClient;
736
+ /**
737
+ * Provides access to the Source Management interface.
738
+ *
739
+ * @example
740
+ * const sources = jules.sources;
741
+ * const allSources = await Array.fromAsync(sources());
742
+ */
743
+ sources: SourceManager;
744
+ /**
745
+ * Creates a new Jules client instance with updated configuration.
746
+ * This is an immutable operation; the original client instance remains unchanged.
747
+ *
748
+ * @param options The new configuration options to merge with the existing ones.
749
+ * @returns A new JulesClient instance with the updated configuration.
750
+ *
751
+ * @example
752
+ * const specialized = jules.with({ apiKey: 'NEW_KEY' });
753
+ */
754
+ with(options: JulesOptions): JulesClient;
755
+ /**
756
+ * Executes a batch of automated sessions in parallel, with concurrency control.
757
+ *
758
+ * @param items The raw data to process.
759
+ * @param mapper A function that transforms each item into a `SessionConfig` object.
760
+ * @param options Configuration for the batch operation.
761
+ * @returns A Promise resolving to an array of `AutomatedSession` objects, preserving the order of the input items.
762
+ *
763
+ * @example
764
+ * const todos = ['Fix login', 'Add tests'];
765
+ * const sessions = await jules.all(todos, (task) => ({
766
+ * prompt: task,
767
+ * source: { github: 'user/repo', branch: 'main' }
768
+ * }));
769
+ */
770
+ all<T>(items: T[], mapper: (item: T) => SessionConfig | Promise<SessionConfig>, options?: {
771
+ /**
772
+ * The maximum number of concurrent sessions to run.
773
+ * @default 4
774
+ */
775
+ concurrency?: number;
776
+ /**
777
+ * If true, the batch operation will stop immediately if any session fails to start.
778
+ * If false, it will continue processing the remaining items.
779
+ * @default true
780
+ */
781
+ stopOnError?: boolean;
782
+ /**
783
+ * The delay in milliseconds between starting each session.
784
+ * @default 0
785
+ */
786
+ delayMs?: number;
787
+ }): Promise<AutomatedSession[]>;
788
+ }
789
+ /**
790
+ * The main entry point for the Jules SDK.
791
+ * This is a pre-initialized client that can be used immediately with default settings
792
+ * (e.g., reading API keys from environment variables).
793
+ *
794
+ * @example
795
+ * import { jules } from 'modjules';
796
+ * const session = await jules.session({ ... });
797
+ */
798
+ export declare const jules: JulesClient;
799
+ export {};